I have a large Excel spreadsheet that I've been asked to expand from 25 to 100 sections. The spreadsheet has a complicated macro that was recorded. Rather than attempt to record a whole new one, I'm trying to understand the VBA so that I can modify the existing macro.
Here is the first part of the macro (this kind of thing repeats over and over)
I have looked around all over the Internet but cannot figure out:
- In (for example) "Selection.AutoFilter Field:=33", what exactly does the number 33 signify? I can't tell...not even from looking at the spreadsheet and knowing what the overall macro is supposed to do!
- I looked up the difference between SmallScroll and LargeScroll...but how in the world is LargeScroll reliable in a macro? It scrolls number of "pages"...but doesn't the number of pages depend on the user's resolution, Excel settings, window size, etc?
- What is the difference between Select and Activate here?
- What do the Selection.Autofilter's that have no criteria accomplish? Anything?
- This macro DOES work for the current version of the spreadsheet, but does all of this recorded code even make SENSE?
Thanks in advance for any help anyone can provide!!
Here is the first part of the macro (this kind of thing repeats over and over)
Code:
Cells.Select
Selection.AutoFilter
ActiveWindow.SmallScroll ToRight:=22
Selection.AutoFilter Field:=33, Criteria1:="0"
Rows("26:561").Select
Range("W54").Activate
ActiveWindow.SmallScroll Down:=9
Selection.Delete Shift:=xlUp
ActiveWindow.LargeScroll ToRight:=-2
Selection.AutoFilter Field:=1
Cells.Select
Selection.AutoFilter
Range("A1").Select
Sheets("Material Cost Estimates").Select
Cells.Select
Selection.AutoFilter
ActiveWindow.SmallScroll ToRight:=2
ActiveWindow.LargeScroll ToRight:=-2
ActiveWindow.SmallScroll ToRight:=20
I have looked around all over the Internet but cannot figure out:
- In (for example) "Selection.AutoFilter Field:=33", what exactly does the number 33 signify? I can't tell...not even from looking at the spreadsheet and knowing what the overall macro is supposed to do!
- I looked up the difference between SmallScroll and LargeScroll...but how in the world is LargeScroll reliable in a macro? It scrolls number of "pages"...but doesn't the number of pages depend on the user's resolution, Excel settings, window size, etc?
- What is the difference between Select and Activate here?
- What do the Selection.Autofilter's that have no criteria accomplish? Anything?
- This macro DOES work for the current version of the spreadsheet, but does all of this recorded code even make SENSE?
Thanks in advance for any help anyone can provide!!