98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA
VBA
Resolved · Low Priority · Version 2007
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
Thu 15 Dec 2011: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Shared Conditional FormattingIn a shared workbook, conditional formats applied before the workbook was shared will continue to work; however you cannot modify the existing conditional formats or apply new ones. |