launch macro using text

mani_singh

Well-known Member
Joined
Jul 24, 2007
Messages
583
hi i have a macro which i need to launch if i click on a populated entry in column c.

i already have the macro ready which currently runs if i highlight the cell (using a worksheet function), if it's populated it takes the data from that cell and runs the macro. i want this to occur if i select the cell.

thanks
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
i'm currently using selectionchange worksheet function, i've tried change worksheet function but its not what i need.

i need it to run if i click on it.

many thanks
 
Upvote 0
Assuming you don't want to fire on a double click just a selection you would need to use the Worksheet_SelectionChange event for that sheet object and then call your other macro parsing say Target.Value to it... if your other macro is not desinged to have the cell reference parsed to it you would need to adjust it:

Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Column = 3 And Len(Target.Value) > 0 Then
    Call OtherMacro(Target.Value)
End If
End Sub

to insert the above right click on the sheet to be used and choose view code and insert.

to adjust other code to accept parsed value:

Code:
Sub OtherMacro(tv As Variant)

End Sub

You may want to change tv to reflect actual data type being parsed (ie Range, Integer, Double, Long, Str) etc...
 
Upvote 0
i'm using this idea currently but i dont want it to run when i highlight the selction, you mentioned double clicking would work. what is the command for this function
 
Upvote 0
If you're au fait with the Worksheet events then go to where you have your selection change event, in the right hand drop down list you will see the events you can "capture" -- one of which is <b>beforedoubleclick</b>

You will want to ensure that again the Target.Row/Column and Value etc meet your crieteria prior to firing subsequent code.
 
Upvote 0

Forum statistics

Threads
1,214,426
Messages
6,119,411
Members
448,894
Latest member
spenstar

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