vba

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Excel VBA Training and help » VBA

VBA

resolvedResolved · 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 courses

 

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
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Excel tip:

Shared Conditional Formatting

In 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.

View all Excel hints and tips


Server loaded in 0.07 secs.