Name Issue

  • Thread starter Thread starter clara
  • Start date Start date
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
 
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

Back
Top