Just need a little help on how to refer to reference the sheet name in this code.
Basically I want the Sheet name to be the value of p
Don't worry, found my mistake, had changed the declaration for the mastersheet, and not amended it further down my code
Code:
Sub GetSheetData()
Dim ws1 As Worksheet, _
ws2 As Worksheet, _
wsm As Worksheet, _
p As String, _
NumLoops As Long, _
WeekSNum As Long, _
X As Long
Set ws1 = Sheets("Sheet1")
Set ws2 = Sheets("Sheet2")
Set wsm = Sheets("Master")
NumLoops = (ws1.Range("D2") - ws1.Range("D1")) / 7 + 1
''Sets the value for NumLoops based on 2 date values in sheet1
WeekSNum = (ws1.Range("D1") - ws1.Range("G1")) / 7 + 1
''Sets the value for WeekSNum based on 2 values in sheet1
X = 0
''Sets the start value for X and Y
Do Until X = NumLoops
p = "Week" & WeekSNum + X
MsgBox p
'Sheets().Range("C6:X6").Copy wsMaster.Range("B1").Offset(X, 0)
X = X + 1
Loop
End Sub
Basically I want the Sheet name to be the value of p
Don't worry, found my mistake, had changed the declaration for the mastersheet, and not amended it further down my code
Last edited: