View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default Click in cell to run macro

I don't have an answer for the "merged cells" problem other than to
say........don't use that feature which causes no end of problems.

If A1:D1 are merged to accommodate a title, use Center Across Selection instead.


Gord

On Tue, 20 Feb 2007 07:25:15 -0800, alistew
wrote:


hi

im back again!

is it possible to use this code on merged cells? i am unsure how merged
cells are recognised. if i merge a1:d1, if you select it the name box will
display it as a1 but this is not recognised in the code. if i enter a1:d1 in
the code this is not recognised. any ideas????

"Gord Dibben" wrote:

You could use doubleclick event code.

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
'Substitute your cells/macro names.
Select Case Target.Address(False, False)
Case "A1"
Cancel = True
MyA1Macro
Case "J10"
Cancel = True
MyJ10Macro
Case "AB275"
Cancel = True
MyAB275Macro
End Select
End Sub

This is sheet event code. Right-click on the sheet tab and "View Code"

Copy/paste the above into that sheet module.


Gord Dibben MS Excel MVP


On Tue, 13 Feb 2007 08:59:02 -0800, alistew
wrote:

Is it possible to click in a cell in Excel to run a macro? assign macro to
cell type thing.