ElvisSteel
Board Regular
- Joined
- Mar 23, 2009
- Messages
- 122
Hi,
I have a large workbook in which I need to create loads of range names (never mind why)
The ranges are to be called "Range_001" to "Range_100"
I am trying to write some code to avoid having to type these in manually.
I recorded the process of naming the first 2 ranges as such...
Range_001
Range_002
Then I tried to create a loop around this code as follows...
...but I need to replace the two C21 in the the Names.Add statement with effectively "C" & s - can someone please advise
Thanks
I have a large workbook in which I need to create loads of range names (never mind why)
The ranges are to be called "Range_001" to "Range_100"
I am trying to write some code to avoid having to type these in manually.
I recorded the process of naming the first 2 ranges as such...
Range_001
Code:
ActiveCell.Range("A1:A25").Select
ActiveWorkbook.Names.Add Name:="Range_001", RefersToR1C1:= _
"='Product Details'!R10C21:R34C21"
Code:
ActiveCell.Range("A1:A25").Select
ActiveWorkbook.Names.Add Name:="Range_002", RefersToR1C1:= _
"='Product Details'!R10C27:R34C27"
Code:
For s = 21 To 615 Step 6
ActiveCell.Range("A1:A25").Select
ProductID = WorksheetFunction.Text((s - 15) / 6, "000")
RangeName = "Range_" & ProductID
ActiveWorkbook.Names.Add Name:=RangeName, RefersToR1C1:= _
"='Product Composer'!R10C21:R34C321"
ActiveCell.Offset(0, 6).Range("A1").Select
Next s
End Sub
Thanks