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

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
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,898
Messages
6,175,274
Members
452,628
Latest member
dd2

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