A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Discussion (Misc queries)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Clickable Cells



 
 
Thread Tools Display Modes
  #1  
Old September 25th 08, 04:32 PM posted to microsoft.public.excel.misc
JSnow
external usenet poster
 
Posts: 54
Default Clickable Cells

Is there any way to assign a macro to a cell instead of a button w/in a cell?
Ideally, I'd like certain cells to be "clickable" and if I can do this w/out
a button - great; if not - so be it.

Thanks in advance.
Ads
  #2  
Old September 25th 08, 04:41 PM posted to microsoft.public.excel.misc
Jim Thomlinson
external usenet poster
 
Posts: 5,942
Default Clickable Cells

You can do that. A better way however IMO is to use double click. Otherwise
any time you move to that cell by enter or arrow keys the macro will run.

Right click on the sheet tab and select view code. Paste the following in
the code window...

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Address = "$A$1" Then
Cancel = True
MsgBox "Tada"
End If
End Sub

When you double click cell A1 a message box appears.
--
HTH...

Jim Thomlinson


"JSnow" wrote:

> Is there any way to assign a macro to a cell instead of a button w/in a cell?
> Ideally, I'd like certain cells to be "clickable" and if I can do this w/out
> a button - great; if not - so be it.
>
> Thanks in advance.

  #3  
Old September 25th 08, 04:50 PM posted to microsoft.public.excel.misc
Rick Rothstein
external usenet poster
 
Posts: 5,934
Default Clickable Cells

It sounds like a SelectionChange event might do what you want. Try this and
see. Right click the tab for the worksheet containing the cell you want to
be "clickable" and select View Code from the popup menu that appears. You
will be placed in the code window for that worksheet. At the top of the code
window are two dropdown boxes... click the left one and select the Worksheet
entry. This should open up to the SelectionChange event automatically. If it
doesn't, then click the right dropdown box and select SelectionChange from
that list. After you have done this, you will see the following...

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

End Sub

Any code you place between these two lines of code will execute whenever you
click into a cell different from the currently active cell (what you click
into will, of course, then become the active cell). Since you only are
interested in having one cell "clickable", you need to filter the
SelectionChange event for that cell. You can do that with this If..Then
block....

If Target.Address = "$B$2" Then

End If

where, for example purposes, I am assuming the cell is B2. Note that the
absolute references are the default for the Address property of a range
(Target is the range for the selection you just made... VB automatically
assigns it for you). Now, anything you put between the If..Then statement
and the End If statement will execute whenever you select B2 (as long as you
did so from a cell other than B2; in other words, a SelectionChange event is
not executed if you click the current active cell since no change in
selection would have taken place).

--
Rick (MVP - Excel)


"JSnow" > wrote in message
...
> Is there any way to assign a macro to a cell instead of a button w/in a
> cell?
> Ideally, I'd like certain cells to be "clickable" and if I can do this
> w/out
> a button - great; if not - so be it.
>
> Thanks in advance.


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a clickable button S Davis Excel Worksheet Functions 1 September 8th 06 04:53 PM
Forms: can a cell itself be clickable? Carmen Gauvin-O'Donnell New Users to Excel 1 August 17th 06 05:59 PM
clickable URL in excel? djarcadian Excel Discussion (Misc queries) 3 May 31st 06 12:01 AM
clickable buttons Murph Excel Discussion (Misc queries) 2 June 22nd 05 07:30 PM
Clickable pie chart - anyone know how this might be achieved? Mark Stephens Charts and Charting in Excel 6 May 7th 05 03:59 PM


All times are GMT +1. The time now is 10:17 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Copyright 2004-2014 ExcelBanter.
The comments are property of their posters.