debug error Y/N

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
667
Office Version
  1. 365
Platform
  1. Windows
hi,


The code below worked fine until I added the line (text in red)

Code:
Sub savetab()

If MsgBox("Do you want to save as a MACRO embedded workbook?", vbYesNo) = vbYes Then
    ActiveWorkbook.SaveAs "C:\Users\data1" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xlsm", 52


Else


[COLOR=#ff0000]If MsgBox("Do you want to save as a MACRO embedded workbook?", vbYesNo) = vbYes Then[/COLOR]
    ActiveWorkbook.SaveAs "C:\Users\data2" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xls", 56


End If
End Sub

which produced the debug error (please click on line to display)

https://www.amazon.co.uk/clouddrive/share/SdCuatmx0DKIJygRc9OmI3vcvgwot4aPLipNQoDm3r5

can some one resolve for me?


KR
Trevor

SdCuatmx0DKIJygRc9OmI3vcvgwot4aPLipNQoDm3r5
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Hi,

try

Code:
Sub savetab()


If MsgBox("Do you want to save as a MACRO embedded workbook?", vbYesNo) = vbYes Then
    ActiveWorkbook.SaveAs "C:\Users\data1" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xlsm", 52




ElseIf MsgBox("Do you want to save as a MACRO embedded workbook?", vbYesNo) = vbYes Then
    ActiveWorkbook.SaveAs "C:\Users\data2" & Application.PathSeparator & ActiveWorkbook.Sheets(1).Name & ".xls", 56




End If
End Sub

Dave
 
Upvote 0
works a treat ..thank you dmt32.

is it possible to have it so it would save both at the same time to the specific locations & have also have the the other 2 options too?

MTIA
Trevor3007
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top