Run VBA by clicking on a cell instead of using ActiveX Control (Command Button)

maclachlan19

Board Regular
Joined
Jul 8, 2013
Messages
53
Most of my spreadsheet are shared by a number of people that use different computer setups, different monitor resolutions and thru a Remote desktop connection.
The Command buttons I use to run some VBA often grow and shrink, often covering up the data.
I have searched and this appears to be an Excel issue.

My question is can you run VBA without using a command button. Perhaps a hyperlink in a cell of the spreadsheet.
 
VBA Code:
Private Sub worksheet_selectionchange(ByVal target As Range)

I tried to add the same code twice on the same sheet and ran into an error.
In the code above can selectionchange be changed to whatever I want this to be meaning I can make this selectionchange2 on my 2nd piece of code.
 
Upvote 0

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
You can use the same worksheet_selection change sub, just add another section to it like this.
If Not Intersect(Range("A3"), target) Is Nothing Then
'do something
End If
 
Upvote 0
To be a bit more clear…

Private Sub worksheet_selectionchange(ByVal target As Range)

If Not Intersect(Range("L5"), target) Is Nothing Then
'do something
End If

If Not Intersect(Range("A3"), target) Is Nothing Then
'do something
End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,875
Members
452,363
Latest member
merico17

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