How To Call A Macro In A Different Module

Sep 11, 2009

I have a macro call psc in one module

in a different module I would like to "call psc"
however, this does not work

View 9 Replies


ADVERTISEMENT

How To Call A Private Module.Macro From Within ThisWorkbook

Oct 17, 2003

When in a ThisWorkbook macro, I want to call a sub/macro in a Module. Usually you can just do a CALL MACRO1, and it will find it. But my MACRO1 is Private as I don't the users to be able to do a Tools, Macro, Macros and see it. So I don't want to make it a Public macro. So how do I call the private sub/macro from within ThisWorkbook?

Can I proceed the sub/macro's name with the name of the module, kind of like CALL MODULE1.MACRO1? Or do I have to make it public?

View 9 Replies View Related

Call/Run Macro Within Same Module Using Common Variable

Feb 3, 2009

The attached file contains a simplified version of a more complex macro in which a sub routine will be called a number of times to change the colours of cells in different ranges. However, an error is triggered because the a variable and range are not defined in the subroutine although they are in the main part of the macro.

I know I am missing something obvious here, but I'd appreciate any help in knowing how I can define the ranges in the main procedure and then call the subroutine to change values in the different ranges.

View 6 Replies View Related

Call A Private Sub From Another Module

Aug 13, 2009

Is it possible to call a Private Sub from another Module?

View 2 Replies View Related

Call Sub Routine From Another Module

Apr 8, 2014

I am writing a lot of code and have separated each section in different modules For example, I have one module titled OpenR2D2 and another titled StoreName

I want the sub in StoreName to run at the end of OpenR2D2 but I get this compile error "expected variable or procedure, not module"

Here's the end of the code where I put it. What have I not thought of?

ThisWorkbook.Activate

Range("B9:G9").PasteSpecial
R2D2data.Activate
Range("B7:G7").Copy 'Sch Actual VLH

ThisWorkbook.Activate

Range("B12:G12").PasteSpecial
Call StoreName
R2D2data.Close Savechanges:=False
Application.ScreenUpdating = True
End Sub

View 4 Replies View Related

Call Public Function From Class Module

May 25, 2006

I have written a public function inside a class module. Is there anyway I could call the public function in Excel? What is the exact syntax to do it?

View 5 Replies View Related

Keeping Track Of Which Macro Is In Which Module Since You Can't Rename The Module?

Mar 27, 2009

After all the awesome macros I've obtained with the help of all of you, I now have over 30 macros, each in its own module. I have tried without success to re-name the modules with no luck. How is everyone organizing these?

View 2 Replies View Related

Macro To Export And Import A Module And Assigning Different Macro Automatically

Jan 27, 2010

Macro to export and import a module and assigning different macro automatically ...

View 9 Replies View Related

Split Up Huge Macro Using Call Macro But Pivot Table Code Errors Out?

Jul 10, 2012

I'm using a CALL Macro to split up a HUGE macro into different pieces:

Code:
Sub RSLDASHBOARDV2()
'Macro recorded 12/14/2010 by Ryan R. Koleno, Pharm.D.
'Last Updated 7/10/12 by Ryan R. Koleno, Pharm.D.
'Do Not Modify Code Unless Given Proper Privileges to do so.
Dim APPSPD As Worksheet
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual

[code]...

The first few macros dealing with page setup and what not work fine but when it hits the Pivot table code for the STATSPIVOT macro it errors out stating: "Run-time error '1004': Unable to get the PivotItems property of PivotField class' at this point in the code:

Code:
objField2.PivotItems( _
"TRC").Position = 1
objField.PivotItems( _
"MEDCO MAIL OR AOB").Position = 2

When this macro is not split up it worked fine as written. Am I overlooking something in the Call Macro's code or is there a variable I'm not aware of. I have included the Pivot Table code that errors out as well.

Code:
Sub STATSPIVOT()
'STATS PAGE BASED ON STATS DATA TAB
Sheets("STATS DATA").Select
Dim objTable As PivotTable, objField As PivotField
ActiveWorkbook.Sheets("STATS DATA").Select
Range("A1").Select

[code]...

View 4 Replies View Related

Call Macro When Clicking In Specific Cell From Personal Macro Workbook

Aug 13, 2014

This is the code I use to call a macro when the macro Im calling is in the same workbook.

[Code].....

However, I would like to call this same macro when using another workbook. I copied the macro "Clearformating" and pasted into a personal macro workbook module. However when I add this code to the sheet tab it will not run the macro.

I also tried this code.

[Code] .....

View 2 Replies View Related

Running A Macro When A Value Is Reached In A Specific Cell Used To Call Up Macro

Jan 7, 2009

I have a Sheet sheet1 and I want to run a macro when the cell D2 in Sheet1 is equal to 10,7,5,and 3. I only want this macro to run when those values are reached the macro then puts the data onto a sheet called wps. The macro is run as a module and is a sub macro.

View 9 Replies View Related

Copy Codes Of Module 1 And Transfer To Module 2?

Jan 24, 2013

Let's say i have 2 Modules on my VBA forms, is it possible to Copy all the Codes in Module 1 and Paste it to Module 2 by using a Command Button?

View 1 Replies View Related

Making Msgbox In One Module With (Yes) Linking To Different Module

Jan 19, 2012

i got a question how i can make a msgbox in one module with 'Yes' linking to a different module.

such as: this is located in module2

Code:
If MsgBox("Do you want to activate module1?" & vbCr & _
"" _
, vbYesNo, "Choose") = vbNo Then Exit Sub

i want that vbYesNo different

No as in Exit Sub

yes as in activate Module1

View 5 Replies View Related

Lookup Function Call: Vlookup Call In Sheet

May 21, 2006

I have a work book with 3 sheets. Sheet 1 is the main sheet and sheets 2 and 3 will use (I hope vlookup) to update 3 columns from info in sheet 1. my attempt at a vlookup call in sheet 2 is: =VLOOKUP($b3,[master_AoJ_2.xls]Sheet1!$B$3;$B$65,false)

my understanding is that: - $b3 is the cell in sheet 2 that will be updated as a result of the vlookup call. - [master_AoJ_2.xls]Sheet1!$B$3;$B$65 refers to range $B$3:$B$65 on sheet1 of master_AoJ_2. it does not work... infact I get nothing at all. when I type the call into cell $b3 of sheet2 excel thinks it is stariaght text. this is how I coded the function call =VLOOKUP($b3,[master_AoJ_2.xls]Sheet1!$B$3;$B$65,false)

View 4 Replies View Related

Add 1 To Cell Value Through Module / Macro

Dec 28, 2008

I need a module that will add 1 to the value of a cell (A1) every ten seconds.

for example:
A1=-200
A1=-199 (after 10 seconds)
A1=-198 (after 20 seconds)
A1=-197 (after 30 seconds)

I found a macro on this forum that I think will work for the first part of such a module (If I modified it correctly). It should give me the ten second timer part of my problem. What I need is the second part of this module to add one to the value of A1. I'm sure it's something simple, but I don't know where to start.

View 11 Replies View Related

Macro Of Only 1 Module Is Displayed

May 29, 2007

While working within the same worksheet, why not put all the routines in one Module instead of using different modules?

BTW, what made me raise the above question is that I have 2 modules in my test worksheet. But when I go to Tools | Macro | Macros > This Workbook, it does NOT show the sub-routines of the first module

View 5 Replies View Related

Need Macro To Call UDF

Apr 29, 2014

I have UDF and would like to use a Macro Button to have it run whenever I need to. Now I have to disable macros with notification in trust center and after entering data, enable content. I have my UDF in a module, is it possible to have another module with a macro so I can run this UDF whenever I need to?

[Code] .....

View 7 Replies View Related

How Does Excel Decide What Module To Put A Macro In?

Nov 5, 2008

I just created a macro in Personal.xls and Excel (for no apparent logical reason) created this macro not in Module 1 (which has no macro or anything else in it, it is blank) but in Module 11.

How does Excel decide what module to put a macro in? Why not choose Module 1?

What's the difference between Module 1 or if I cut the macro from Module 1 and pasted it into Sheet 1 of Personal.xls which is blank?

View 7 Replies View Related

Delete A Macro Using A Script That I Have In A Module

Feb 27, 2007

I have macro in ThisWorkBook that runs when I open the workbook

Private Sub Workbook_Open()

I would like to to delete this macro using a script that I have in a Module. There is another macro in ThisWorkBook which I want to keep.

View 3 Replies View Related

Calling Module In Module With Variables

Oct 25, 2011

What i have at the moment is a module that contains code where i call a different module that i use as a procedure.

Module1

Code:
If Sheet1.Range("C4").Value < Sheet1.Range("A2").Value Then
If Sheet1.Range("K4") = "" Then
MsgBox "Please check 06:00 tasks not done yet!"
Cell = "Range(" & Chr(34) & "F4" & Chr(34) & ")"
If Sheet1.Range("C4") + 0.042 < Sheet1.Range("A2") Then
Run "EmailProSheet"
End If
End If
End If

EmailProSheet is what i call but now i want to use the variable "Cell" in the procedure as well?

Module3

Code:
MsgBox Cell
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next

[Code]........

As it is now everything is working fine but does not return a value in "Cell" if the procedure is called. Is there another way?

View 5 Replies View Related

Call Macro Using Variable As Name

Feb 7, 2014

I am trying to run different macros by clicking various different buttons on the sheet, I then want different data to load into the user form depending which button was pressed. So I have buttons named "SV_1" and another named "SV_2". when either button is pressed then it runs a common macro that gets the name of the calling item. then I want to add "Macro" to the beginning of the calling item name and then call that macro. here is the code that I am working with, when using a watch i can see the value of the variable is "MacroSV_1" when button 1 is pressed but I cannot get it to run the Sub.

VB:
Public ClkBtn As String
Public CallMacro As String

Sub ItemCall()

[Code] ......

View 5 Replies View Related

Call From Within Macro Script Sub In Another Xla Add-in?

Jun 25, 2014

I am trying to write a sub that executes a sub in an xla add-in. How can that be done in general?

More specifically I am wondering whether it can be done with the limited info that I have about the add-in and the to be executed macro within the add-in.

assume the name of the xla add-in is test.xla. The add-in is locked. I therefore do not know the name of the sub to be executed nor do I know the "on action" name of the sub in the ribbon. All I have is the Ribbon button label. Assume the ribbon button label is "ButtonLabel".

Is it possible to call the macro just by knowing the ribbon button label? If yes, how does the script look like assuming the above xla and button name?

View 5 Replies View Related

How Do I Call A UserForm From Within A Macro

Nov 14, 2008

I've created a simple UserForm, and with some great help from royUK. I've managed to get it working to suite my needs. The next thing I need to do is call it when the user runs the macro.

How do I call the UserForm from within the macro that I created?

Once the user gives the input, how do I take the values and pass them to the loop in the macro?

View 11 Replies View Related

Call Macro From Different Workbook

Oct 8, 2009

I have created a custom menu and saved it as an .xla, one of the functions on the menu is to open up a workbook from a file path. The second option on the menu is to run a macro from the custom menu that is saved in this opened workbook.

Is it possible to write a code that will go off and find this macro from this open workbook?

The reason I wanted to do this is so the user has two options to enter data from however I didn't want to copy the macro over from the original workbook as in time the workbook will be updated

View 10 Replies View Related

Call Macro From Text Value

Mar 13, 2012

I have a named range, which pulls a text value from a vlookup. This text is the name of a vba sub I have written. What I would like to do, is call the macro based on this value. This is what I have so far but I can't get it to run.

Code:

Sub ControlSheets()
ActiveSheet.Calculate

Hideallsheets
Dim MacroSub As String
MacroSub = sheets("Control").Range("SheetMacro").Value
Call MacroSub 'this is the name taken above that i want to call

End Sub

View 2 Replies View Related

Call Stored Macro

Jul 6, 2009

Any way to actually execute a macro stored as a text file?

Without being long winded - I want to create different macro and physically save them as text files. Once saved - I could call them from a list.

View 9 Replies View Related

Hyperlink To Call A Macro

Jun 20, 2006

can i use a hyperlink to call/invoke a macro...?

View 5 Replies View Related

Call Macro With An Argument

May 7, 2007

i want to create a lot of buttons, one in each line, that, when you click on them, open a file. The filename is in a cell in the same row as the button.

Of course every button should open a different file, and that is the problem. As far as i know (not very much) the buttons can only call other subs, and not with an argument.

What should i put into the "onAction" property of each button, so that each button opens a different file? I really dont want to create hundreds of subs just to get this done, there must be another way.

PS: By the way, how can i delete all but one buttons of a sheet with a vba script? Or shall I open another post for that?

View 3 Replies View Related

Assigning Macro/Module To Specific Sheet

May 27, 2009

I have a workbook that has 2 similar worksheets. One called "Wood Shafts" and the other called "Iron Shafts" I have the macros worked out for the sheet called "Wood Shafts" and I just realised I need to apply similar Macros to the sheet called "Iron Shafts" (same functions but different values from different columns). Some how I need the code to be able to tell the difference between the two sheets. I am at a loss.

View 4 Replies View Related

Run Macro That Resides In A Private Sheet Module

Mar 26, 2008

I have a sheet that has a macro on it, I would like to run that macro programaticaly but Im not able to call it using Call mymacro type of code. The code that calls the macro resides in a module and the macro is in a sheet. Obviously they are not talking, is there a way to run it remotely without moving the macro into the module?

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved