run a macro from a value in a cell

AndyD

Active Member
Joined
Nov 14, 2002
Messages
449
hi there
I have an index formula in a cell, so for example it could return "macro1" or "macro2".

What vba do i need do runs the macro mentioned in the cell?

Cheers

Andy
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Put below code to your vba page (your sheet which contain there index)
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Target.SubAddress = "" Then Run (Target.Name)
End Sub

this way work when you set the index to hyperlink
you can use below code to set your index to hyperlink
if you index kept in column "A"
Code:
For K = 1 To [A1].End(xlDown).Row
ActiveSheet.Hyperlinks.Add cells(K,1), "", "", , cells(K,1).Value
Next
 
Upvote 0
Hi Thanks for your reply

its actually a little bit different to this...i dont want a macro to automatically run when the value in the cell is changed.

I want users to press a "create report" button that does something first (macro_part_1) then runs the macro in the cell for part 2

Hope makes sense?
Cheers
Andy
 
Upvote 0
Is this code as you want?
Code:
For K = 1 To [A1].End(xlDown).Row 
Run cells(K,1)
Next
 
Upvote 0

Forum statistics

Threads
1,214,636
Messages
6,120,664
Members
448,976
Latest member
sweeberry

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