Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default activate code on single click

you can't single click - this would be the same as selecting the cell, so
you can use the SelectionChange method

"sunilpatel" wrote in message
...
Is there a way to activate code on a "Single" click in the activecell /
selected cell on sheet.

i have "no" in cell "a1" and it is selected. i want it to change to "yes"
if i single clik on "a1"

Probably not possible hey?

Sunil

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default activate code on single click

Single click? No. But if you are willing to use a double click (which I
think is more natural and it would avoid accidentally changing a value when
the user clicks into a cell by mistake)...

Private Sub Worksheet_BeforeDoubleClick(ByVal _
Target As Range, Cancel As Boolean)
If InStr(1, "*Yes*No*", "*" & Target.Value & "*", vbTextCompare) Then
Cancel = True
Target.Value = Mid("YesNo", 1 - 3 * (Len(Target.Value) = 3), 3)
End If
End Sub

You can add code to filter this for specific ranges if that is what you
need.

--
Rick (MVP - Excel)


"sunilpatel" wrote in message
...
Is there a way to activate code on a "Single" click in the activecell /
selected cell on sheet.

i have "no" in cell "a1" and it is selected. i want it to change to "yes"
if i single clik on "a1"

Probably not possible hey?

Sunil


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default activate code on single click

Yes. By using a hyperlink and a hyperlink event macro.

First select A1 and:
Insert Hyperlink... to a place in this document
then pick cell A1 and give it the name "no"

This looks pretty useless. We have created a hyperlink that goes nowhere!

However, then insert the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
For Each h In ActiveSheet.Hyperlinks
If h.SubAddress = "Sheet1!A1" Then
h.TextToDisplay = "yes"
End If
Next
End Sub


Now if we click on A1, the macro fires and changes the visible text to "yes"

Without the hyperlink, we would have to rely on a double-click event.

--
Gary''s Student - gsnu200852


"sunilpatel" wrote:

Is there a way to activate code on a "Single" click in the activecell /
selected cell on sheet.

i have "no" in cell "a1" and it is selected. i want it to change to "yes" if
i single clik on "a1"

Probably not possible hey?

Sunil



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,049
Default activate code on single click

clever.

"Gary''s Student" wrote in message
...
Yes. By using a hyperlink and a hyperlink event macro.

First select A1 and:
Insert Hyperlink... to a place in this document
then pick cell A1 and give it the name "no"

This looks pretty useless. We have created a hyperlink that goes nowhere!

However, then insert the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
For Each h In ActiveSheet.Hyperlinks
If h.SubAddress = "Sheet1!A1" Then
h.TextToDisplay = "yes"
End If
Next
End Sub


Now if we click on A1, the macro fires and changes the visible text to
"yes"

Without the hyperlink, we would have to rely on a double-click event.

--
Gary''s Student - gsnu200852


"sunilpatel" wrote:

Is there a way to activate code on a "Single" click in the activecell /
selected cell on sheet.

i have "no" in cell "a1" and it is selected. i want it to change to "yes"
if
i single clik on "a1"

Probably not possible hey?

Sunil



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default activate code on single click

The Target object is the Hyperlink object that was clicked on, so this can
be further simplified by using the code shown below.

Also, if you plan on using this with multiple links, then use Select Case
statements in place of the If, Then, Else statements.

Example:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Dim l_strSheetName As String
l_strSheetName = Target.Parent.Name
Select Case Target.SubAddress
Case "A1"
Target.TextToDisplay = "yes"
End Select
End Sub


--
Thanks,

Ronald R. Dodge, Jr.
Production Statistician
Master MOUS 2000
"Gary''s Student" wrote in message
...
Yes. By using a hyperlink and a hyperlink event macro.

First select A1 and:
Insert Hyperlink... to a place in this document
then pick cell A1 and give it the name "no"

This looks pretty useless. We have created a hyperlink that goes nowhere!

However, then insert the following event macro in the worksheet code area:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
For Each h In ActiveSheet.Hyperlinks
If h.SubAddress = "Sheet1!A1" Then
h.TextToDisplay = "yes"
End If
Next
End Sub


Now if we click on A1, the macro fires and changes the visible text to
"yes"

Without the hyperlink, we would have to rely on a double-click event.

--
Gary''s Student - gsnu200852


"sunilpatel" wrote:

Is there a way to activate code on a "Single" click in the activecell /
selected cell on sheet.

i have "no" in cell "a1" and it is selected. i want it to change to "yes"
if
i single clik on "a1"

Probably not possible hey?

Sunil







  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 57
Default activate code on single click

Is there a way to activate code on a "Single" click in the activecell /
selected cell on sheet.

i have "no" in cell "a1" and it is selected. i want it to change to "yes" if
i single clik on "a1"

Probably not possible hey?

Sunil


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change syperlink from single click to double click syperlinker Excel Worksheet Functions 0 June 13th 08 05:01 PM
The cell I click on when coming from another app doesn't activate Dave Excel Discussion (Misc queries) 1 October 4th 07 11:01 AM
Change single click to double click AucklandAssault Excel Programming 4 March 6th 07 07:26 PM
activate VB code for any WS in a single WB itsthebike[_6_] Excel Programming 0 July 8th 06 02:19 AM
Scrollbar single click acts like click and hold Ken Shaffer Excel Programming 0 December 5th 05 07:06 PM


All times are GMT +1. The time now is 08:53 AM.

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

About Us

"It's about Microsoft Excel"