ваша проблема заключается в
1) отсутствии полностью квалифицированных диапазонов вплоть до их рабочего листа и родителей рабочей книги
2) Workbooks.Add
, что сделает вновь созданную рабочую книгу "активной "один и его первый рабочий лист" Активный "тоже
Итак, после того, как вы получили ваш комментарий, вы запускаете подпрограмму, активированную кнопкой ActiveX, и что Range("rng_counter")
и Range("rng_forms_count")
находятся в на том же листе, в то время как все остальные диапазоны отсутствуют, вы можете попробовать это (пояснение в комментариях):
Private Sub CommandButton1_Click()
With Me ' reference the sheet with button
Application.Calculation = xlCalculationAutomatic
Dim i As Long
For i = .Range("rng_counter").Value To .Range("rng_forms_count").Value
If Worksheets("Reporting Form Template").Range("C9").RowHeight > 165.6 Then '***This part is to mention an issue that would come up in the report made
MsgBox "There is an issue with the AEs of Respondent ID - " & .Range("rng_ae_number") & ", the AE form would extend beyond the intended height of the form,(write down this Respondant ID and do it seperately, its report would not be generated) consider reducing the font size of AEDump to make sure the report comes in 2 pages instead of 3!"
Else
.Range("rng_counter").Value = i 'update "rng_counter" named range in referenced sheet
Calculate
.Parent.Worksheets("Reporting Form Template").Range("A1:Q14").Copy ' copy a fully qualified range up to its workbook parent
With Workbooks.Add ' open and reference a new workbook. this will become tha "active" one
With .Worksheets(1).Range("A1") ' reference referenced workbook first worksheet (which has become the "active" one) range A1
.PasteSpecial Paste:=xlPasteAllUsingSourceTheme, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
End With
End With
End If
Next i
End With
End Sub