Solved

second macro to run before the first one has completed

Posted on 2014-01-09
4
250 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 50

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

792 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