vba
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

VBA

resolvedResolved · Low Priority · Version 2007

replyReply Wed 7 Dec 2011, 12:48Delegate Laura said...

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

For upcoming training course dates see: Pricing & availability

replyReply Fri 9 Dec 2011, 11:14Trainer Simon said...

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.

 

Please browse our web site to find out more about
excel vba training course london and other Microsoft training courses.

Excel tip:

Hiding and unhiding columns using the keyboard

CTRL + 0 hides your columns and CTRL + SHIFT + ) unhides them although you would need to highlight the column letters either side as per normal

View all Excel hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard