Activate macro after clicking on a particular cell

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What do I have to code in order to call a macro after a select, or clikc on a
paricular cell?, for example, I would like to run the macro after a select
the cell A10 or a range of cells that have a format of merge so they look
like a big cell ?
Thanks
 
Which is it: A10 or a range of cells that have a format of merge so they
look like a big cell?
 
hi tom, i've got same question as moises, how can i start macro once a cell,
with a pulldown list, has a value entered?
 
I have both cases, one with a single cell like A10, and the second case a
range of cells with a merge format so they are displayed as a big cell (for
example range b2..d3, with a merge format).
Thanks
 
Right click on the sheet tab and select view code and put in code like this

Private Sub Worksheet_Change(ByVal Target As Range)
Set rng = Target.MergeArea
Select Case rng.Address(0, 0)
Case "A10"

Case "B2:D3"

End Select
End Sub

then call the procedures within the case statements or put your code there.
 
I have a similar issue. I tried the solution listed here and it worked... a
little too well. In the Private Sub Worksheet_Change(ByVal Target as Range)
(I'm not clear on what the ByVal Target as Range does,) the macro makes
changes to the worksheet. Specifically, it inserts a row in the current
worksheet and copies some formulas from an adjacent row.
The problem with this is that the Private Sub is calling itself when it
makes the change since the Sub causes the change that activates itself. This
sends the macro into an infinite loop whenever I make a change and I have to
ctrl+break to regain control. The macro stops in the middle of execution and
restarts. Any ideas on how to make the macro only execute once or only
execute when the user makes the change instead of the macro?
 
Tom,
How far away am I from getting this to work? I try and avoid macros at all
costs and I am now knee deep in this. Can you spare a moment to advise? I am
trying to get a calendar form to appear when a user selects either cell B9 Or
Cell C9 in the concerned worksheet....Thanks in advance for whatever advice
you can supply...

Walt
 
oops:

Private Sub Worksheet_Change(ByVal Target As Range)
Set rng = Target.MergeArea
Select Case rng.Address(0, 0)
Case "B9"
Sub OpenCalendar()
' Displays the UserForm and calendar
' Shortcuts should be made to this procedure
End If

Case "C9"
Sub OpenCalendar()
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top