Programming a checkbox in Excel
On May 23, 10:56 am, Tom Ogilvy
wrote: right click on the sheet tab. Select View code. In the left dropdown at the top of the module select Worksheet and on the right dropdown select BeforeDoubleclick. this will put in a code declaration for the Beforedoubleclick event. Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean) End Sub This event will fire whenever the sheet is double clicked, before the normal action of the double click is executed. The cancel argument allows you to cance that normal action. Now you need to add code to perform the function you want whenever the cell triggering the event (held as a reference in the target variable) is the cell you are interested in. For example for cell F9 to have this functionality Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _ Cancel As Boolean) If Target.Address = "$F$9" Then Cancel = True Target.Font.ColorIndex = 3 If Trim(LCase(Target.Value)) = "x" Then Target.ClearContents Else Target.Value = "X" End If End If End Sub Make sure you only have one BeforeDoubleClick event in your sheet module. -- Regards, Tom Ogilvy " wrote: Hello, I am very unfamiliar with programming VB and Macros in excel. Here is the situation. I would like to have a check or an "X" appear in a cell when it is double clicked. Can someone please help me with that? Thank you! Lauren- Hide quoted text - - Show quoted text - Thank you! That worked beautifully |
All times are GMT +1. The time now is 01:34 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com