Meegan_Brown
New Member
- Joined
- Mar 4, 2019
- Messages
- 2
Hi- I am new to learning VBA and I need some help! I am looking for a VBA code that will loop through all 50 tabs within an excel workbook and search for any named range that starts with EQUITY and copy and paste all named ranges into one single tab within the workbook. In this case we can name that tab MASTER.
I explored using Paste Range and specified ranges like so:
Sub PasteRange()
Range("EQUITYO1JY").Copy
Range("A2").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
End Sub
This was fine until I realized I'll have close to over 100 named ranges, and I would have to update the code if a new named range were to be added, as well as a location for it to be pasted to.
As a note, all named ranges have the same number of columns, however the number of rows varies. (Not sure if this makes a difference)
Any help would be much appreciated!
I explored using Paste Range and specified ranges like so:
Sub PasteRange()
Range("EQUITYO1JY").Copy
Range("A2").PasteSpecial (xlPasteValues)
Application.CutCopyMode = False
End Sub
This was fine until I realized I'll have close to over 100 named ranges, and I would have to update the code if a new named range were to be added, as well as a location for it to be pasted to.
As a note, all named ranges have the same number of columns, however the number of rows varies. (Not sure if this makes a difference)
Any help would be much appreciated!