OilEconomist
Active Member
- Joined
- Dec 26, 2016
- Messages
- 439
- Office Version
- 2019
- Platform
- Windows
Hello and thanks in advance and I will provide feedback to any assistance on solutions.
I'm trying to name range a large amount of cells and would like to use a VBA loop to do it. I am naming a column of cells from (20, 3) to (20, 69). That's 50 cells in column C starting on the 20th row and ending on the 69th row. Please note, these range names are only specific to "Sheet2" (a single worksheet) and not the workbook.
I'm getting errors such as "Error" "Object Required" on the line "If i < 10 Then Set RangeName = "T.0" & i" and "&" gets highlighted/
Here is my code thus far:
I'm trying to name range a large amount of cells and would like to use a VBA loop to do it. I am naming a column of cells from (20, 3) to (20, 69). That's 50 cells in column C starting on the 20th row and ending on the 69th row. Please note, these range names are only specific to "Sheet2" (a single worksheet) and not the workbook.
I'm getting errors such as "Error" "Object Required" on the line "If i < 10 Then Set RangeName = "T.0" & i" and "&" gets highlighted/
Here is my code thus far:
Code:
Sub NameRange1()
Worksheets("Sheet2").Activate
Dim i As Integer
Dim LastRow As Long
For i = 1 To 2
Range(19 + i, 3).Select
If i < 10 Then Set RangeName = "T.0" & i
Else: Set RangeName = "T." & i
Next i
End Sub