szita2000
Board Regular
- Joined
- Apr 25, 2012
- Messages
- 101
- Office Version
- 365
- Platform
- Windows
Hi All.
I am trying to refer to a worksheet by a string which is value of a cell.
This is my code for this part:
On the Set y row it craps out with subscript out of range error.
How can I set y to the name of the worksheet that is month?
I was going with the same syntax we use for referring to named ranges. Am I missing something?
Here are my Variables
Dim month As String
Dim y As Worksheet
Dim brlastrow As Integer
Dim bigrange As Range
I am trying to refer to a worksheet by a string which is value of a cell.
This is my code for this part:
Code:
month = Sheet15.Range("K1").Value 'This is the string with the name of the worksheet (User selectable)
Set y = Worksheets("month") 'Here I want to set which sheet we will run the code on
brlastrow = y.Range("A" & Rows.Count).End(xlUp).Row 'here I want to find the lastrow on that sheet
Set bigrange = y.Range("C2:C" & brlastrow) 'Here I would set the range for my loop
On the Set y row it craps out with subscript out of range error.
How can I set y to the name of the worksheet that is month?
I was going with the same syntax we use for referring to named ranges. Am I missing something?
Here are my Variables
Dim month As String
Dim y As Worksheet
Dim brlastrow As Integer
Dim bigrange As Range