Advertisement

07.22.2008 at 02:42PM PDT, ID: 23586711
[x]
Attachment Details

How to reference a 'named range' from Excel using VBA?

Asked by stltodaycom in Visual Basic Programming, Microsoft Excel Spreadsheet Software

Tags: ,

I am using the following code to insert a new row:
==============================
Range("B9", "J9").Select
ActiveCell.Offset(0, 0).Select
Selection.EntireRow.Insert
Selection.EntireRow.Interior.ColorInde... = xlNone
Selection.EntireRow.Font.Bold = False
Selection.EntireRow.Font.ColorIndex = 32
Selection.EntireRow.Borders(xlEdgeBottom... = 0
==============================

I want to call a 'named range' that I've established in Excel instead of
hardcoding the cell values like I am doing above: Range("B9", "J9").Select.

I am saying 'named range', but I think it is actually called 'Name Box' in Excel. (It's in the upper left hand corder beneath the file and edit menu.

How do I reference this in code? For example, I have a named range called "Objective 2".

How do I reference 'Objective 2' instead of hardcoding cell A and cell B like I am already doing?

I tried doing this but it doesn't work:
Range("Objective2").Select
ActiveCell.Offset(0, 0).Select
etc..

Thanks!

DK
Start Free Trial
Related Solutions: VBA ; Excel ; help with Insert
[+][-]07.22.2008 at 02:50PM PDT, ID: 22064037

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Visual Basic Programming, Microsoft Excel Spreadsheet Software
Tags: VBA, Excel
Sign Up Now!
Solution Provided By: saurabh726
Participating Experts: 2
Solution Grade: A
 
 
[+][-]07.22.2008 at 02:54PM PDT, ID: 22064065

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.22.2008 at 04:21PM PDT, ID: 22064591

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_Related_20080208