Solved

Given a single-cell named range, what expression gives a range of the cell's row?

Posted on 2011-02-21
10
248 Views
Last Modified: 2012-05-11
A worksheet cell has been named" r_Cell".  
What is the expression that will provide a range with r_Cell's entire row?

Dim v_RowRange as Range

Set v_RowRange = ?    '// create a range that is the entire row of range("[r_Cell]")
0
Comment
Question by:AndresHernando
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
10 Comments
 
LVL 12

Accepted Solution

by:
Alan3285 earned 125 total points
ID: 34941145

Hi,

I think this is what you need:

    set v_RowRange = range(r_Cell).entirerow

Alan.
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34941152
Hello,

maybe like

Sub test()

Dim v_RowRange As Range
Dim cRow As Long
cRow = Range("r_cell").Row
Set v_RowRange = Range(cRow & ":" & cRow)
v_RowRange.Select


End Sub

Open in new window


cheers, teylyn
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34941155
Ahww! Alan, much better!!
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34941162
.... although, you may want to include the quotes around r_Cell, like

    Set v_RowRange = Range("r_Cell").EntireRow

cheers, teylyn
0
 
LVL 12

Expert Comment

by:Alan3285
ID: 34941197
Yes - Depends on what he means by 'named' cell.

If it is 'named' in VBA something like:

set r_Cell = Range("A1")

then no quotes, but if 'named' in the normal user interface outside of VBA then he would need the quotes.

Alan.
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34941289
I work a lot with range names / named formulas / named ranges .... whatever you want to call them. So my antennae flag this as a range name (as in Insert > Name > Define or "Name Manager" in XL 2007 or later).  

That's my gut feel. I could be wrong. It could be a variable, but when I read ...

>> A worksheet cell has been named" r_Cell".  

... my antennae say "named range"!

In any case: as a VBA variable without quote marks, or as a named range with quote marks, your suggestion wins, if I had a say.

cheers, teylyn
0
 
LVL 50

Expert Comment

by:Ingeborg Hawighorst
ID: 34941355
Then again, if it's a VBA variable, you would not wrap it in a Range(), would you? More like ...

dim r_Cell as range
set r_Cell = Range("A1")

    set v_RowRange = r_Cell.entirerow

Open in new window

0
 
LVL 12

Expert Comment

by:Alan3285
ID: 34941501
Hi Teylyn,

Re-reading the OP, I agree that he probably means a defined name using Insert > Name > Define (or the "Name Manager" in later versions).

In that case, the quotes would be required.

Thanks,

Alan.
0
 

Author Comment

by:AndresHernando
ID: 34941509
Thank you both for the info!  --Andres
0
 
LVL 12

Expert Comment

by:Alan3285
ID: 34941646
Probably should have split the points, but thank you.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question