debug error Y/N

Trevor3007

Well-known Member
Joined
Jan 26, 2017
Messages
675
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

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
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,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

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