Solved

second macro to run before the first one has completed

Posted on 2014-01-09
4
244 Views
Last Modified: 2014-01-09
Hi Expert's Excel 2007

I have a macro which does a simple copy cut and paste special. ..works great...however..I need a macro to prompt the user to save the file first before the copy and paste macro runs. ..just in case they accenditally press the copy and paste macro button by error and delete all the formula. ..

both macros to run off one button. ...ill simply call the other macro..
0
Comment
Question by:route217
  • 2
4 Comments
 
LVL 13

Assisted Solution

by:Alexander Eßer [Alex140181]
Alexander Eßer [Alex140181] earned 250 total points
ID: 39767867
You could override "Workbook_BeforeSave" as shown here http://datapigtechnologies.com/blog/index.php/forcing-users-to-save-as-xlsm/ and then just save your workbook from within VBA before calling your macro...
0
 

Author Comment

by:route217
ID: 39767915
Ok thanks for the feedback...how do I call the private sub. ...

these guys have no vlue on vba....do everything had to run via a button. ..
0
 
LVL 49

Accepted Solution

by:
Rgonzo1971 earned 250 total points
ID: 39767929
HI,

you coud try this

Sub MacroSaveBefore()
Result = MsgBox("Do you want to save your workbook before" & vbCrLf & "replacing the formulas with values?", vbYesNo, "Paste values")
If Result = vbYes Then
    ActiveWorkbook.Save
End If
'Rest of your code

End Sub

Open in new window


EDIT  a bit more sophisticated
Sub MacroSaveBefore()
Result = MsgBox("Do you want to save your workbook before" & vbCrLf & "replacing the formulas with values?", vbYesNoCancel, "Paste values")
If Result = vbYes Then
    ActiveWorkbook.Save
ElseIf Result = vbCancel Then
    MsgBox "Operation cancelled", vbOKOnly, "Stop"
    Exit Sub
End If
'Rest of your code

End Sub

Open in new window

Regards
0
 

Author Closing Comment

by:route217
ID: 39767948
Thanks for the excellent feedback. .
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This Article is a follow-up to my Mappit! Addin Article (http://www.experts-exchange.com/A_2613.html), it was inspired by an email posting I made to EUSPRIG (http://www.eusprig.org/index.htm), I will briefly cover: 1) An overvie…
This tutorial explains how to create a series of drop-down lists that are dependent upon prior selections to guide (“force”) the user to make the correct selection and reduce data errors within Microsoft Excel. Excel 2010 was used for this tutorial;…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question