Free Microsoft Excel 2013 Quick Reference

Running macro within a macro

When using a call function in a macro to excute a different macro and using
the shortcut key, it skips the called macro. But when the macro is selected
in the tool macro menu selection and manually run it works. Is there a
method to slow down the orginal macro until the called macro is completed?

Thanks in advance...


Pardon if I posted this twice - hit a key and my first post disappeared.

I am attempting to run a macro within a macro - I have a loop and I need to run several macros inside the loop, then update the date (what the offsets do) and run through again. This is what I am trying with one macro:

	VB:
	
 mcrFullRun() 
     '
    Dim r As Long, Start As Range 
     
    Set Start = Range("StartYear") 
    r = 0 
     
    Do Until Start.Offset(r, 0).Row > Range("E9") 
        Range("C4") = Start.Offset(r, 0) 
        Range("C4").NumberFormat = Start.Offset(r, 0).NumberFormat 
        Range("C5") = Start.Offset(r, 1) 
        Range("C6") = Start.Offset(r, -1) 
        r = r + 1 
        MsgBox "Date is assigned" 
         
        Application.Run "DOLoop_Model1.xls!mcrCopyLags" 
        MsgBox "Lags are copied" 
         
    Loop 
     
End Sub 

If you like these VB formatting tags please consider sponsoring the author in support of injured Royal Marines
This runs the code and the macro once, then stops after I acknowledge the message box. I confirmed I am within my do until range.

how do I run multiple macros within one macro?

Is there any way to create a macro that prompts users for certain information
or requests users to do a specifice task? I'm asking because I need to create
a macro that compiles data from multiple files then sorts/organizes said
data. The problem is that neither the file naming nor the layout of the data
within the spreadsheet is standardized (i.e. Net Income may be found in cell
J52 on "Q01-05 Net Income.xls" and N87 on "Q2-2005 NI.xls").

Also, is it possible to run a macro within a macro? I guess that would just
be extra steps within one big macro, but if possible I'd like to break steps
down into individual macros and then just have one master macro.

Thanks in advance

comparini3000

Is there any way to call in another written macro within a macro. What I want to do is split my dataset in different ways and plot. So i was thinking to write a macro that plots. And within the macro that splits the data, I could call the macro that plots. If so, how can i do this?

Is therre a way to stop a running macro with a command button? I have a macro that continually loops on purpose and need to know if there is a way I can have a command button stop the macro if it is pressed while the macro is looping?

Thanks,

How can I execute another macro within a macro? Example, I have a macro called "GoTo()". Within this macro, I want to call on another macro called "Consolidate()".

The code for Consolidate is very lengthy and I don't want to insert this code into my other macro.

Thanks

Is there a way to allow a macro to run within a shared workbook? It is a simple sorting macro and even this won't work when shared?

How can you execute a macro within another macro.

Example: Run macro a in macro b. Cutting and pasting does not seem to work.

Hi and morning,

how do you run a macro within another macro.

eg if user inputs '1' into cell ref A1 run macro called goto1
else exit sub

thanks

Hi
I have a macro which tidies up before it does some copy/paste. I want the macro "TransDataBase"to run then call another macro "DeleteRowOnCell", then finish running the first macro (TransDatabase). At present it stops after running "DeleteRowOnCell"

Portion of "TransDatabase:
Columns("j:j").Replace What:="L", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByColumns, MatchCase:=False
Columns("j:j").Select
Application.Run "PERSONAL.XLS!DeleteRowOnCell"
Range("Data").Select
Range("LastData").Activate
Selection.Copy

Pretty clueless on VBA. Tks

Hi and Many thanks in advance!!!

AT present I am using a public variant to know which one is the active workbook containing the running macro.

the macro starts when :
HTML Code:
Private Sub Workbook_Open()
Set ActiveWkb = ActiveWorkbook
End Sub
and then declaring the vatiable within a module this way:
HTML Code:


* * *

I would like to use one other system.

since all my macros are attached to a menu, and this menu is attached to a workbook.

the macros within this menu could and actually are prepared, some times, to work in other open workbooks.

but I would like to activate tha workbook containing the manu "the workbook that creates the menu" to be the active workboook, once the macro has finish the tasks.

* * *

is the re a way to know the name of the workbook, containing the running macros?
know a running macro's workbook name
without using public variables!

so if thisWorkbook.name="Thanks"

and this book contains a macro named "Macro1" within a menu.
when I press the menu to run the macro1

get the name of the book=thanks

kinf of:

msgbox application."running containing macro's workbook name"

thanks!!

What is the command to disable a macro within another macro? For example, I have a macro called MyMacroA and I want to disable MyMacroB from running when MyMacroA is running. How do I do this - what is the specific command?

Any help much appreciated. Thanks.

I would like to run a macro if the criteria within a "IF" function is TRUE

eg. IF(g12=0,"run macro") can this be accomplished withing the formula or do
I have to create it in VBA? I'm not at all familiar with Visual Basic.
I'm trying to hide selected rows when a given value is equal to zero. Is
there an easy way to accomplish this? Thanks for your help

I have 4 macros that create 4 reports. I have a 5th macro that runs all 4 macros so creates all 4 reports if I need them all.

All macros have a message box pop up to day they're complete. Of course this means the 5th "all reports" macro has 4 "I'm complete" message boxes".

I really only want one message box to appear for the "all reports" macro. Is there a clever way to suppress the 4 individual messages boxes?

If we could run more than one macro per button than it would be easy but of course we can't.

Is it possible to run a macro from within a formula?

eg =If(A1="yes", run macro, " ")

I hope it is! please help me here

Thanks

A couple years ago i made a giant spreadsheet and had 2 custom toolbars to run macros from to manipulate the sheet.

This year i re-did the sheet, meaning all my old data was replaced (it's a giant schedule basically).

However, the Macros in the custom toolbars stayed exactly the same and performed the same function and are directed to the exact same cells, rows, columns, etc..

But now when i hit the buttons on the custom toolbars to run my macros, i get the following message... all the time...

**
A document with the name "NHLsheet.xls" is already open. You cannot open two documents
with the same name, even if the documents are in different folders.
To open the second document, either close the document that's currently open, or rename one of the documents.
**

Trouble is, i have only 1 document open!
There's something in the macros that thinks i'm trying to open a new document but i'm clueless as to where or why.. they are very simple macros
that do not require the opening of any new workbooks..

All they do is point to another sheet within my open workbook, "NHLsheet", copy a particular row from that sheet, and paste it to a specific spot onto another sheet within my workbook, "NHLsheet".

Here is a sample:

Sub ANAhome()
'
' ANAhome Macro
' Macro recorded 04-02-2008 by ...
'

'
    Sheets("DefenceStats").Select
    Rows("2:2").Select
    Selection.Copy
    Sheets("tester").Select
    Rows("5:5").Select
    ActiveSheet.Paste
    Sheets("OffenceStats").Select
    Rows("2:2").Select
    Selection.Copy
    Sheets("tester").Select
    Rows("10:10").Select
    ActiveSheet.Paste
    Sheets("SpecialTeams").Select
    Rows("2:2").Select
    Selection.Copy
    Sheets("tester").Select
    Rows("15:15").Select
    ActiveSheet.Paste
End Sub
I think it has to do with the fact that i created these macro toolbars 2 years ago for use in the workbook i had used 2 years ago..

though nothin has really changed..

I can't figure out why it insists that there is another copy of "NHLsheet" open somewhere??

Can anyone help?

thanks,

Hi

I am trying to get my macro to run subsequent macros. I have performed a column check from a separate extract then the next macro is a sterilisation.
But for some reason it wont run automatically.
Is there something I'm missing?????

Here is my script:

On Error Resume Next
MkDir ("C:export")
MkDir ("C:exportexporttemp")

Application.DisplayAlerts = True

' standardise
Application.Run ("REPORTS_template TDBV.xlsb'!data_sterilisationVer2")

' tempXXXXX files
Application.Run ("REPORTS_template TDBV.xlsb'!Temps_reportsVer2") ' find the path

' updated clauses on the REPORTS_template TDBV.xlsx summary pages by removing calculated references to a "Today()" cell in REPORTS_template TDBV.xlsb
'(TLDR; more speedy)
Application.Run ("REPORTS_template TDBV.XLSB!Summary_Dates")

Dim OutApp As Object
Dim OutMail As Object
Dim OutApp2 As Object
Dim OutMail2 As Object

' generate the customer reports
Application.Run ("REPORTS_template TDBV.XLSB!export_report_macro_part_1_Ver2")

Application.DisplayAlerts = True

End Sub

' and relax...

The guide to "Excel VBA: Automatically Run Excel Macros When a Cell Changes/Enter Data. Worksheet Change Event" was helpful in getting me started, but I couldn't do what I wanted. Here is what I want: When I type in data to a cell and press enter, I want a previously created macro to run.

Hi all,

Can anyone tell me if there is a way to automatically run a macro when a named sheet becomes the active sheet. I don't want the user to have to enter a value in a cell, but just by selecting the sheet using a sheet tab, cause the macro to run.

Thank you for any advice.

Regards,

CDT

I have macro within a spreadsheet that opens an other template, this template does some calculations and result is pasted to clipboard. I wish to close this template (without saving) without a dialog box appearing and asking me if I wish to save it.

Hi !

I use Excel a lot but don't understand VBA much.

I have looked at a series of Change Event topics and code but can't see what I need.

I simply want a macro to run automatically when a cell ....which contains the Maximum time from a range.... changes.

I assume I use .... Private Sub Worksheet_Change(ByVal Target As Excel.Range) ...but I have no idea what code to use...

can anyone help ??

Thanks.

Colin

Whenever I share a workbook, I experience problems running macros that are problem-free otherwise. I’ve read the help menu about restrictions of using shared workbooks, but I did not run across anything that might explain this behavior. I’ve experimented with a few spreadsheets and I run across this problem in all cases. Can anyone help with an explanation or past experience? I’m assuming that by sharing a workbook, the workbook is automatically protected for both windows and structure. If this is what is causing the problem, is there code I can use to still allow my macros to run trouble free in a shared workbook?

situation: I am created a sceduled task within an ACCESS
dB to export out information to a .csv network file share.
The problem is that the date field is illegible it appears
in date-time format and when opened appears as
2.00512E+13. The ACCESS export is always writing over the
same file.

Is it possible to create a macro within this network file
share .csv which will format the columns, perform a LEFT
(datefield,8) on the date field trimming off the time so
that just the date appears as 20051231 and then format
this date field to appear as 12-31-2005 and then sort the
entire worksheet by date while assigning this macro to a
smiley face as a custom command on the toolbar also with
autoexec feature.

The objective being that all users throughout the network
will have a shortcut on their desktop pointing to the
network .csv file share so the macro is invoked upon
opening the file and the user can then look at a file
which makes sense vis-a-vis the date field.

Note: I attempted this but I was not able to save the
macro to the .csv. WHen I reopened the .csv I receive an
error message that the macro created cannot be found.

Thank you very much in advance!

I currently run macros from a VB application, and my code within
the app looks something like:

ShellExecute(0&, vbNullString, "excel", q & file_to_operate_on & q & q & file_macro_is_in & q, vbNullString, vbNormalFocus)

However, I wanted to ask, suppose file_macro_is_in has many macros defined
in it, and I want to execute only one particular one. Does Excel have any
command line arguments that would allow me to do this? For instance,
making something along the lines of the following possible:

ShellExecute(0&, vbNullString, "excel", q & file_to_operate_on & q & q & file_macro_is_in & q & "-mymacroname", vbNullString, vbNormalFocus)

Also, so that I don't ask too many questions that could probably be answered
by some reading, can anyone recommend a source for thorough documentation
on the Excel API + command line arguments to Excel? Thank you.