User Profile
lisae
Copper Contributor
Joined Mar 06, 2019
User Widgets
Recent Discussions
Macro to sort range within a sheet, then re-do for 100+ sheets
I recorded a macro to highlight a range (A3:J47) in a worksheet (2012_03), then to sort on column J in descending order. The macro performed correctly. I have 100+ identical worksheets that I want to perform this same macro on and I can not get it to work. When I choose a different worksheet (such as 2012_04) and run the macro, only the range is selected, and the sort is performed on the original worksheet (2012_03) but not the active worksheet (2012_04). Help! Here is the VBA code that I can make little sense of (I'm a newbie, obviously): Sub SortRows() ' ' SortRows Macro ' ' Range("A3:J47").Select ActiveWorkbook.Worksheets("2012_03").Sort.SortFields.Clear ActiveWorkbook.Worksheets("2012_03").Sort.SortFields.Add2 Key:=Range("J3:J47" _ ), SortOn:=xlSortOnValues, Order:=xlDescending, DataOption:=xlSortNormal With ActiveWorkbook.Worksheets("2012_03").Sort .SetRange Range("A3:J47") .Header = xlGuess .MatchCase = False .Orientation = xlTopToBottom .SortMethod = xlPinYin .Apply End With End Sub512Views0likes0Comments
Recent Blog Articles
No content to show