Forum Discussion
Counting names
Hans,
Thanks for taking the time to give me a hand with this workbook. I have never worked with macros, so I am struggling to fully understand what needs to be done. I have made what I thought were the obvious changes to the macro, but when I run it I get nothing but an error message. When I run the debug I get:
Sub Work_Party_Total()
'
' Work_Party_Total Macro
'
'
ChDir "C:\Users\dwojm\OneDrive\Documents"
ActiveWorkbook.SaveAs Filename:= _
"https://d.docs.live.net/0b2e42162b4a9117/Documents/Annual%20work%20party%20total.xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
ActiveWindow.SmallScroll Down:=-45
Sheets("Sheet2").Select
End Sub
I have attached a sample of what I want to use. I just used 2 months instead of all 12. If you would be kind enough to take a look and point me in the right direction, I would be grateful. When this is done I am going to take some time and try my hand a a few macros. I am 78 years old and have always been pretty basic with my excel files. I guess it is time for me to exercise my brain a little.
Thanks,
Denny Olson
The code should be copied into the code module in the Visual Basic Editor, not into a worksheet.
It requires a few changes: in your monthly sheets, first name is in column C, last name in column B, and NCRR is column D. You need to change the constants FNCol etc. accordingly.
And the data in those sheets begin in row 4, not - as I had assumed - in row 2.
See the attached version.
You can run the macro ListNames in either of the following ways:
- In Excel, press Alt+F8 to activate the Macros dialog. Select ListNames, then click Run. Or:
- Press Alt+F11 to activate the Visual Basic Editor, click anywhere in the code of the ListNames macro, and press F5 to run it. Switch back to Excel to view the result.
The macro that you mention won't work; among other things, it refers to a non-existent sheet Sheet2.
- ftb1ssApr 08, 2021Copper ContributorOnce again, thanks for the assist. I will sit down with it next week and see if I can get it to run. I am wrapped up with grand kid for the next few days. They say you can't teach an old dog new tricks. You can, it just takes a little longer.
Denny Olson