Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excell copy action pauses for 15 second for the smallest action | Excel Discussion (Misc queries) | |||
How do I insert a cell which changes value when clicked on | Excel Discussion (Misc queries) | |||
How can i undo an action after i have clicked save. | Excel Discussion (Misc queries) | |||
Perform action if value in cell - conditional VB stmt | Excel Discussion (Misc queries) | |||
%1 appears in "Application used to perform action" when trying to edit a file type | Excel Worksheet Functions |