Loop through code based on Range Names

mrattenborough

New Member
Joined
Oct 4, 2004
Messages
11
THe Code below is repeated for each range name. THe issue is that the code exceeds 64k when all range names are accounted for and wont compile. I am sure there is a better way to do this and would appreaciate any guidence.

The Range names would change at NoRecords = Range("RangeName").value and Selection.AutoFilter Field:=1, Criteria1:=AreaHotel4Name and Range("SPAH4").Select. Other than that the code is the same for each range name.

I have approx 70 Range names that I need to process.


'Check to see if there is any data for this Plan
NoRecords = Range("SPAH4Rows").Value
If NoRecords > -11 Then

'Find Last Row
LastRow = Range("A65536").End(xlUp).Row

Range("A1").Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Range("A1:G" & LastRow - 1).Select
Selection.AutoFilter
Selection.AutoFilter Field:=1, Criteria1:=AreaHotel4Name
CurrRow = ActiveCell.Row + 1

'Refresh Last Row based on returned set
LastRow = Range("A65536").End(xlUp).Row

Range("B" & CurrRow, "F" & LastRow).Select

Selection.Copy
Sheets("Smart Plans").Select
Range("SPAH4").Select
Application.Range(ActiveCell, ActiveCell.End(xlToLeft)).Select

Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False

'Goto Action Plans
With Sheets("Action Plan Input")
.Activate

'Clear AutoFilter
ActiveSheet.AutoFilterMode = False
End With

End If


Any assistance is appreciated. Thank you
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Forum statistics

Threads
1,224,591
Messages
6,179,771
Members
452,941
Latest member
Greayliams

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top