Doble click a cell and running a macro

  • Thread starter Thread starter Cristian
  • Start date Start date
C

Cristian

Hi

Is there any posibility by clicking or double-clicking a cell in a
range to run a macro?

What I am trying to do is, if a user clicks (or double clicks) on a
cell in a range the coresponding worksheet is unhide.

I am passing the ActiveCell.Value as a parameter to a function which
unhides the coresponding sheet. (the value of the cell is the name of
the sheet to unhide).

I don't know how to make the connection between clicking on the cell
(actually a range of cells) and the macro.

Thank you
Cristian
 
One way:

Put this in the worksheet code module:

Private Sub Worksheet_BeforeDoubleClick( _
ByVal Target As Excel.Range, Cancel As Boolean)
If Target.Address(False, False) = "J10" Then
Cancel = True
MyMacro1 Target.Value
End If
End Sub

in a regular code module:

Public Sub MyMacro1(ByVal sIn As String)
Worksheets(sIn).Visible = True
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