Solved

second macro to run before the first one has completed

Posted on 2014-01-09
4
224 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 48

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Drop Down List with Unique/Distinct Values (enhancing the Combo-Box with a few steps and a little code) David miller (dlmille) Intro Have you ever created a data validation list from a database field or spreadsheet column (e.g., Zip Codes or Co…
Workbook link problems after copying tabs to a new workbook? David Miller (dlmille) Intro Have you either copied sheets to a new workbook, and after having saved and opened that workbook, you find that there are links back to the original sou…
Viewers will learn the basics of slicers and timelines for both PivotTables and standard Excel tables in Excel 2013.
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now