Morning All
I have two workbooks. The active workbook does some calculations/ has some user input, and then a macro is used to move certain entries to a second workbook.
Both workbooks are set up using code names as somebody will inevitably change the worksheet name at some point (!) but when I try and reference the code name of the second workbook I get a "Compile error: Argument not optional"
I've attached my code below - it's the last two rows that seem to be the problem. If I take my option explicit off then the code will open the WBSuspense, but not be able to find "Log" (which is the correct codename)
just wondering if anyone has any idea what I've done wrong?
Thanks in advance!
Jon
I have two workbooks. The active workbook does some calculations/ has some user input, and then a macro is used to move certain entries to a second workbook.
Both workbooks are set up using code names as somebody will inevitably change the worksheet name at some point (!) but when I try and reference the code name of the second workbook I get a "Compile error: Argument not optional"
I've attached my code below - it's the last two rows that seem to be the problem. If I take my option explicit off then the code will open the WBSuspense, but not be able to find "Log" (which is the correct codename)
just wondering if anyone has any idea what I've done wrong?
Thanks in advance!
Jon
VBA Code:
Sub Move_To_Suspense()
Dim LRow, LRowSuspense As Long
Dim WBMaster, WBSuspense As Workbook
Dim SuspenseFP As String
Set WBMaster = ThisWorkbook
SuspenseFP = Range("suspensefp")
HHC.Activate
LRow = Cells(Rows.Count, 1).End(xlUp).Row
Range("a2:i" & LRow).AutoFilter field:=9, Criteria1:="Suspense"
If Range("a2:a" & LRow).SpecialCells(xlCellTypeVisible).Count = 1 Then
HHC.ShowAllData
Instructions.Select
MsgBox "No rows to move to suspense"
Exit Sub
End If
Set WBSuspense = Workbooks.Open(Filename:=SuspenseFP)
Log.Activate