I'm now getting run-time error 91 with it highlighting my variavle rng1 as not being set. The code worked previously but now on re-opening the file isn't working.
If someone could please let me know what I need to alter here in my code I'd greatly appreciate it.
Dim x As Integer
Dim y As Integer
Dim variableRange As String
Dim concatRange As String
Dim programmeMatch As String
Dim rng1 As Long
x = 3
y = Workbooks("Overnights Calculator - 1 min.xlsm").Worksheets("Data").Cells(5, 15)
Do Until x = y + 1
variableRange = "Q" & x & ":" & "AB" & x
concatRange = "AF" & x
programmeMatch = Workbooks("Overnights Calculator - 1 min.xlsm").Worksheets("toreport").Range(concatRange).Value
Windows("Overnights Calculator - 1 min").Activate
ActiveWorkbook.Sheets("toreport").Range(variableRange).Select
Selection.Copy
rng1 = Workbooks("UK_Consolidated_1920_MASTER.xlsm").Worksheets("Master Data").Range("AC:AC").Find(programmeMatch)
Windows("UK_Consolidated_1920_MASTER").Activate
Workbooks("UK_Consolidated_1920_MASTER.xlsm").Worksheets("Master Data").Range("q" & rng1).PasteSpecial Paste:=xlPasteValues
x = x + 1
Workbooks("Overnights Calculator - 1 min.xlsm").Worksheets("Data").Cells(5, 13) = x
Loop
Windows("UK_Consolidated_1920_MASTER").Activate
Workbooks("UK_Consolidated_1920_MASTER.xlsm").Save
If someone could please let me know what I need to alter here in my code I'd greatly appreciate it.
Dim x As Integer
Dim y As Integer
Dim variableRange As String
Dim concatRange As String
Dim programmeMatch As String
Dim rng1 As Long
x = 3
y = Workbooks("Overnights Calculator - 1 min.xlsm").Worksheets("Data").Cells(5, 15)
Do Until x = y + 1
variableRange = "Q" & x & ":" & "AB" & x
concatRange = "AF" & x
programmeMatch = Workbooks("Overnights Calculator - 1 min.xlsm").Worksheets("toreport").Range(concatRange).Value
Windows("Overnights Calculator - 1 min").Activate
ActiveWorkbook.Sheets("toreport").Range(variableRange).Select
Selection.Copy
rng1 = Workbooks("UK_Consolidated_1920_MASTER.xlsm").Worksheets("Master Data").Range("AC:AC").Find(programmeMatch)
Windows("UK_Consolidated_1920_MASTER").Activate
Workbooks("UK_Consolidated_1920_MASTER.xlsm").Worksheets("Master Data").Range("q" & rng1).PasteSpecial Paste:=xlPasteValues
x = x + 1
Workbooks("Overnights Calculator - 1 min.xlsm").Worksheets("Data").Cells(5, 13) = x
Loop
Windows("UK_Consolidated_1920_MASTER").Activate
Workbooks("UK_Consolidated_1920_MASTER.xlsm").Save