Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Naming a range with specified location

Status
Not open for further replies.

Ramy27

Technical User
Apr 26, 2005
63
GB
Sorry guys, am new to programming in that i only rarely use VBA. Whenever i come to use VBA, i forget even the basics, cos i didn't use vba for a long time.

When a user enters an excel range (Example "Sheet1!C5:G13" ) in a specified excel cell ,the program should re-name this range as "RangeA"


I tried recording a macro, but it didn't help

Range("C5:G13").Select
ActiveWorkbook.Names.Add Name:="RangeA", RefersToR1C1:="=Sheet1!R5C3:R13C7"


---------------------------------
"Good things are the enemies of the best things"
---------------------------------
 

It's not clear exactly what you are trying to accomplish, but this will do what you asked:
Code:
Sub test()
  ActiveWorkbook.Names.Add Name:="RangeA", RefersToR1C1:=ActiveCell.Text
End Sub
if you select the cell with "Sheet1!C5:G13" in it and then run the macro, the range name will be created.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top