Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Perform action when cell is clicked

I need help,
I am trying to write a module that will change the value
of a cell when a different one is selected.

For example - user clicks on B1 (only selecting the cell -
no change of value) and C1 value would then show "Y" - if
B1 were clicked again then C1 would change to "".

I can figure everything out except how to make excel/VBA
recognize that a cell has been clicked.

Thanks for any advice!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Perform action when cell is clicked

Jason,

Put the following code in the sheet code module for the appropriate
worksheet.


Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Address = "$B$1" Then
Application.EnableEvents = False
If Range("C1") = "Y" Then
Range("C1") = ""
Else
Range("C1") = "Y"
End If
Application.EnableEvents = True
End If
End Sub


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
www.cpearson.com


"Jason" wrote in message
...
I need help,
I am trying to write a module that will change the value
of a cell when a different one is selected.

For example - user clicks on B1 (only selecting the cell -
no change of value) and C1 value would then show "Y" - if
B1 were clicked again then C1 would change to "".

I can figure everything out except how to make excel/VBA
recognize that a cell has been clicked.

Thanks for any advice!



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Perform action when cell is clicked

Jason,

Put the following code in the sheet code module for the appropriate
worksheet.


"Jason" wrote in message
...
I need help,
I am trying to write a module that will change the value
of a cell when a different one is selected.

For example - user clicks on B1 (only selecting the cell -
no change of value) and C1 value would then show "Y" - if
B1 were clicked again then C1 would change to "".

I can figure everything out except how to make excel/VBA
recognize that a cell has been clicked.

Thanks for any advice!



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Perform action when cell is clicked

Hi

Rightclick the sheet tab, choose "View code". Paste this into the module
that appear:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$B$1" Then
If Cells(1, 3).Value = "Y" Then
Cells(1, 3).Value = "N"
Else
Cells(1, 3).Value = "Y"
End If
End If
End Sub

--
HTH. Best wishes Harald
Followup to newsgroup only please

"Jason" skrev i melding
...
I need help,
I am trying to write a module that will change the value
of a cell when a different one is selected.

For example - user clicks on B1 (only selecting the cell -
no change of value) and C1 value would then show "Y" - if
B1 were clicked again then C1 would change to "".

I can figure everything out except how to make excel/VBA
recognize that a cell has been clicked.

Thanks for any advice!



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
Excell copy action pauses for 15 second for the smallest action Meekal Excel Discussion (Misc queries) 1 January 28th 10 04:30 PM
How do I insert a cell which changes value when clicked on JohnRScott Excel Discussion (Misc queries) 2 March 13th 09 04:31 AM
How can i undo an action after i have clicked save. missy Excel Discussion (Misc queries) 2 December 8th 08 05:43 PM
Perform action if value in cell - conditional VB stmt Studebaker Excel Discussion (Misc queries) 2 February 29th 08 06:34 PM
%1 appears in "Application used to perform action" when trying to edit a file type [email protected] Excel Worksheet Functions 3 December 7th 06 07:00 PM


All times are GMT +1. The time now is 07:38 PM.

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

About Us

"It's about Microsoft Excel"