Forum

Invalid Forward Ref...
 
Notifications
Clear all

Invalid Forward Reference When Run Macro.

2 Posts
2 Users
0 Reactions
118 Views
(@cmrosso)
Posts: 1
New Member
Topic starter
 

Hello, I have this macro that was running correctly until Dec 29.  Now, I have an error in the line below, could you please help me to understand the error?

Thankserror-VBA.png

 

Sub AdvanceFilter_Copy()

Dim rgdata As Range

Dim rgCriteria As Range

Dim rgOutput As Range

Dim Rg As Range

Set Rg = ThisWorkbook.Worksheets("Output").Range("A1").CurrentRegion

Rg.Offset(1).Clear

Set rgdata = Workbooks("filename.xlsm").Worksheets("Schedule-A").Range("A11").CurrentRegion Error Here

Set rgCriteria = ThisWorkbook.Worksheets("Ultera Scheduled Time").Range("J2").CurrentRegion

Set rgOutput = ThisWorkbook.Worksheets("Output").Range("A1").CurrentRegion

rgdata.AdvancedFilter xlFilterCopy, rgCriteria, rgOutput

MsgBox "Hi " & Application.UserName & _

vbNewLine & "The report has been updated", , "Schedule A"

End Sub

 
Posted : 06/01/2021 3:43 pm
(@catalinb)
Posts: 1937
Member Admin
 

Workbooks("filename.xlsm") requires the source file to be open, make sure it is.

Check also if sheet name is indeed Schedule-A

 
Posted : 06/01/2021 11:28 pm
Share: