Tanyaann1995
Board Regular
- Joined
- Mar 24, 2021
- Messages
- 62
- Office Version
- 2016
- Platform
- Windows
Hi,
I have below code which saves an .xlsm file in same folder and edits the name. But, I'm getting run time 1004 error after the below highlighted line. Please can anyone explain why.
I have below code which saves an .xlsm file in same folder and edits the name. But, I'm getting run time 1004 error after the below highlighted line. Please can anyone explain why.
VBA Code:
Sub editable(control As IRibbonControl)
Dim xWs As Worksheet
Dim wb As Workbook
Set wb = ActiveWorkbook
ActiveWorkbook.save
wb.Worksheets(2).Range("A:K").Copy
wb.Worksheets(2).Range("A1").PasteSpecial Paste:=xlPasteValues
wb.Worksheets(2).Columns("L:AH").EntireColumn.Delete
Application.DisplayAlerts = False
For Each xWs In Application.ActiveWorkbook.Worksheets
If xWs.Name <> "Emerson COMMERCIAL OFFER" Then
xWs.Delete
End If
Next
Application.DisplayAlerts = True
[COLOR=rgb(184, 49, 47)]ActiveWorkbook.SaveAs ActiveWorkbook.path & "\" & wb.Worksheets(1).Range("F11")[/COLOR]
End Sub