I'm pretty novice at programming Macros and coding VB so this is must be very basic question but I can't figuring it out by myself. I have recorded a Macro that moves and arranges some cells around my worksheet .it works wonderful until I tried to apply this Macro on another worksheet and then it stopped working right were the file name of the previous document was. My question is how to replace the filename in the macro with a veritable or current worksheet statement so it will work always with every file that I want.
Example:
![]()
Range("P2:P240").Select ActiveWorkbook.Worksheets("Download (6)").Sort.SortFields.Clear ActiveWorkbook.Worksheets("Download (6)").Sort.SortFields.Add Key:=Range("P2" _ ), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("Download (6)").Sort .SetRange Range("A2:AT17") .Header = xlNo .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With











LinkBack URL
About LinkBacks
Register To Reply

Bookmarks