running macro from VBA in excel

VBAmalta89

Board Regular
Joined
Mar 25, 2011
Messages
116
I have recorded a macro in excel and i need it to run at a particular instant in a user form in VBA.

Is there any way of doing this?

Thanks
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
That depends on when the "particular instant" is. When the form loads? When a field on the form changes? When the user presses a button? At a particular time of day? When the form unloads?
 
Upvote 0
So I have a dropdown menu in a user form which contains a list of options taken from an excel worksheet. Now the user will select one option. Each option is related to another set of lists in a worksheet.

What I want to do is when the user picks example option A a particular set of options are visible in the next drop down box (combo box), but if he selects option B in the first combo box, then the set of options in the second combo box are different and taken from another list.

Now I managed to achieve the above, however, what is happening is that in the second combo box the options aren't in order and tehre are a number of blank spaces between some of them. This is due to the way they are sorted in teh excel worksheet.

I created a macro to sort them with no spaces in the excel worksheet and I need this macro to run every time a particular option is made from the first combo box.

This is an example of the code I have currently:

Private Sub proc1_Change()
Select Case proc1.Value
Case Is = "Drilling": ZoneSelect1.RowSource = " 'Dropdown Menu Info'! D20:D27"
Case Is = "Turning": ZoneSelect1.RowSource = " 'Dropdown Menu Info'! E20:E27"

EndSelect
EndSub

Can you understand my problem?
 
Upvote 0
Just call the other macro at the appropriate point of your code. Maybe something like this:-
Code:
Private Sub proc1_Change()

  Select Case proc1.Value
    Case Is = "Drilling": ZoneSelect1.RowSource = " 'Dropdown Menu Info'! D20:D27"
    Case Is = "Turning": ZoneSelect1.RowSource = " 'Dropdown Menu Info'! E20:E27"
  EndSelect
 
  [COLOR=red]Call other_macro[/COLOR]

End Sub
Is that what you mean?
 
Upvote 0
yes...whts the coding i need to use to call the macro though?

As Rorya says, that - the bit in red - was the coding: it's the command Call followed by a space followed by the name of the other macro.

Hey, does Colonel G still own the Jerma Palace Hotel in Marsascala?
 
Upvote 0
yep ok I managed.

@ruddles: the jerma hotel is long gone my friend it was demolished a few years back and its just an abandoned site nowadays!
 
Upvote 0
Another memory consigned to the rubble of history! :(

I dived with Ray Ciancio from the dive centre next door to the Jerma Palace.
 
Upvote 0

Forum statistics

Threads
1,224,600
Messages
6,179,836
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top