Name Issue

C

clara

Hi all,

the following is my current code:
For Each t In Sheets("Tasks").Range("A2:A500")

I'd like to define a name refer to ("A2:A500") and use that name in the
above code, how can I do it.

Clara
 
G

Gary''s Student

Dim clara as String
clara="A2:A500"
For Each t In Sheets("Tasks").Range(clara)
 
J

JLGWhiz

Here is one way:

Sub fh()
Sheets(1).Range("B2:B5").Name = "SomeName"
End Sub

You can also just use a variable for code purposes:

SomeName = Range("B2:B5")

The difference is that when you use the range name as the object it would be
Range("SomeName") and is a range object. The other would be a variable that
could be used as a value - SomeName - or a range - SomeName.Address and a few
other variations depending on your declarations.
 

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

Similar Threads

How to refer a name in VBA 4
Arithmetic with Cell Dates 1
Conditional select range 20
VBA Help 2
Automatic range adjustment when copying data 1
user form VBA 4
Message box help 1
Delete rows that cell value is "No" 4

Top