Hi, I cannot figure out why I'm getting this compiling error. It happens when it hits the first "sheets" selection line. Any halp would be appreciated. thanks.
Dim Week1 As String
Dim Week2 As String
Dim MyName As String
MyName = ThisWorkbook.Name
Week1 = Worksheets("SSE Paste").Range("B400") 'This references a cell with a sheet name that populates based on a criteria. Values are like "Jul 9" for actual existing sheet names
Week2 = Worksheets("SSE Paste").Range("B401") '" "
ActiveWorkbook.Save
If Format(Date, "ddd") = "Fri" Then 'on Fridays i need it to select two sheets to be copied and sent
Sheets(Week1, Week2).Select 'this is the line where its stopping and saying "compile error: wrong number of arguments or invalid property assignment"
On Error GoTo 0
Else
Sheets(Week1).Select 'if its not Friday, i need it just copy and send one sheet
End If
Activesheets.Copy
Application.DisplayAlerts = False
ActiveWorkbook.BreakLink Name:= _
"\\10.1.100.245\scheduling\HCVR\Global HCVR\-Templates\" & "MyName" & ".xls", _
Type:=xlExcelLinks
ChDir "\\10.1.100.245\scheduling\HCVR\Global HCVR"
ActiveWorkbook.saveas FileName:= _
"\\10.1.100.245\scheduling\HCVR\Global HCVR\PM_Operations_Variance.xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.Dialogs(xlDialogSendMail).Show _
"PM Operations Variance", "PM_Operations_Variance.xls"
Application.DisplayAlerts = True
End Sub
Dim Week1 As String
Dim Week2 As String
Dim MyName As String
MyName = ThisWorkbook.Name
Week1 = Worksheets("SSE Paste").Range("B400") 'This references a cell with a sheet name that populates based on a criteria. Values are like "Jul 9" for actual existing sheet names
Week2 = Worksheets("SSE Paste").Range("B401") '" "
ActiveWorkbook.Save
If Format(Date, "ddd") = "Fri" Then 'on Fridays i need it to select two sheets to be copied and sent
Sheets(Week1, Week2).Select 'this is the line where its stopping and saying "compile error: wrong number of arguments or invalid property assignment"
On Error GoTo 0
Else
Sheets(Week1).Select 'if its not Friday, i need it just copy and send one sheet
End If
Activesheets.Copy
Application.DisplayAlerts = False
ActiveWorkbook.BreakLink Name:= _
"\\10.1.100.245\scheduling\HCVR\Global HCVR\-Templates\" & "MyName" & ".xls", _
Type:=xlExcelLinks
ChDir "\\10.1.100.245\scheduling\HCVR\Global HCVR"
ActiveWorkbook.saveas FileName:= _
"\\10.1.100.245\scheduling\HCVR\Global HCVR\PM_Operations_Variance.xls", _
FileFormat:=xlExcel8, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=False, CreateBackup:=False
Application.Dialogs(xlDialogSendMail).Show _
"PM Operations Variance", "PM_Operations_Variance.xls"
Application.DisplayAlerts = True
End Sub