Laura has attended:
Excel VBA Intro Intermediate course
VBA
How do you name a range of cells from within VBA.
For example, I would like the code to select cells A1:C1 and name the range "Headers"
Thanks
RE: VBA
Hi Laura,
Thank you for your question and welcome to the forum.
The following code belows names a range and copies and paste the range to another range of cells:
Range("c1:f1").Name = "TestThis" ' rename the range
Range("TestThis").Copy ' refer to the name and copy
Range("g1").PasteSpecial ' paste the named range
application.cutcopymode = false ' stops the marching ants around the selection copied
You can also use named ranges for Vlookup formulas.
I hope this answers your question.
Regards
Simon