ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Call a macro or sub based on the name of a cell? (https://www.excelbanter.com/excel-programming/275256-re-call-macro-sub-based-name-cell.html)

steve

Call a macro or sub based on the name of a cell?
 
Jack,

I got this to work in Excel 97

Run ("module1." & Target.Name.Name)

where "module1" is the name of the module. (don't forget the period)

--
sb
"Jack Labonte" wrote in message
om...
Hi,

I have about 20 named cells and I want to to execute a sub based on
the name of the cell. For example, a user double-clicks on a cell and
they get prompted for an input box based on the needs for the
calculation for the cell. I know I can trap the address but that's too
hard to keep track of. So far I've tried trapping with
target.name.name like so:


Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel
As Boolean)

on error resume next

Select Case target.name.name

Case is = Worksheets("Drawings").Range("Board1")

'Do something...

End Select

End Sub


Is there any way to do something based on the cell name rather than
the cell address?

Thanks,

JL





All times are GMT +1. The time now is 07:01 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com