Trouble Naming Range

M

Michael Smith

Having trouble naming a range...

Dim rng as Range
Set Rng.....

I need rng to be the length of my sheet...trying to name it and its
failing on me.


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
 
R

Ron de Bruin

Hi

Do you mean this(example for the A column)

Sub test()
Dim rng As Range
Set rng = Sheets("sheet1").Range("A1:A" & Sheets(1).Range("A" & Rows.Count).End(xlUp).Row)
MsgBox rng.Address
End Sub
 
T

Tom Ogilvy

Dim rng as Range, i as Long
' set i to the column you need
i = 3
set rng = Range(cells(1,i),cells(rows.count,i).End(xlup))
rng.Name = "MyName"

msgbox Range("MyName").Address(external:=True)
msgbox Thisworkbook.Names("MyName") _
.RefersToRange.Address(external:=True)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top