Harshil Mehta
Board Regular
- Joined
- May 14, 2020
- Messages
- 85
- Office Version
- 2013
- Platform
- Windows
I have 7 sheets in total and want to make save as for the first 5 sheets with time stamp and password.
The below code gives an error msg "wrong number of arguments or invalid property assignment" highlighting the word FORMAT.
This code used to work perfectly before adding the the 7th sheet. The 7th sheet is a place where Raw Data is dumped and with the help of the VBA Code the data is populated into different sheets.
Could anyone please help me?
The below code gives an error msg "wrong number of arguments or invalid property assignment" highlighting the word FORMAT.
This code used to work perfectly before adding the the 7th sheet. The 7th sheet is a place where Raw Data is dumped and with the help of the VBA Code the data is populated into different sheets.
Could anyone please help me?
VBA Code:
Sub Make_SaveAs()
Dim ArrayOne() As String
Dim Mypassword As String
Application.ScreenUpdating = False
Mypassword = Sheets(6).Range("E2")
ReDim ArrayOne(1 To 5)
For i = 1 To 5
ArrayOne(i) = Sheets(i).Name
Next
Worksheets(ArrayOne()).Copy
With ActiveWorkbook
.SaveAs Filename:=Environ("USERPROFILE") & "\Desktop\" & Format(Now(), "YYYYMMDD -") & " Client Design - " & ThisWorkbook.Sheets(6).Range("D2") & "_" & ThisWorkbook.Sheets(6).Range("C2") & ".xlsb", FileFormat:=xlExcel12, Password:=Mypassword
.Close SaveChanges:=False
End With
Application.ScreenUpdating = True
MsgBox "File Saved on Deskstop"
End Sub