![]() |
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! |
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! |
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! |
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! |
All times are GMT +1. The time now is 11:16 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com