ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with Check Box and VBA (https://www.excelbanter.com/excel-programming/293197-help-check-box-vba.html)

wlatif

Help with Check Box and VBA
 
Hi,

I am new to excel and I am not sure if what I want is doable or not,
would really appreciate your help;

I want to create a two columns sheet in the first column I want a chec
box in the next column a date field. When the user checks the check bo
the current date and time would be put in the date column this way
can tell when that task was done. If the check mark is unchecked th
second cell needs to be cleared out if a date was there already.

If you can help me with both how to create the check box and how t
attach the code to it to do the above it will be great.

Thanks

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

Help with Check Box and VBA
 
Hi,

Here is a solution that doesn't use a checkbox, but does put a check mark in
the column. Just copy the code into the worksheet code module (right-click
on the sheet name tab, select View Code, and paste the code in). Try it!

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

With Target
If .Column = 1 Then
If .Value = "a" Then
.Value = ""
.Font.Name = "Arial"
.Offset(0, 1).Value = ""
Else
.Value = "a"
.Font.Name = "Marlett"
.Offset(0, 1).Value = Format(Date, "dd mmm yyyy")
End If
.Offset(0, 1).Activate
End If
End With
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"wlatif " wrote in message
...
Hi,

I am new to excel and I am not sure if what I want is doable or not, I
would really appreciate your help;

I want to create a two columns sheet in the first column I want a check
box in the next column a date field. When the user checks the check box
the current date and time would be put in the date column this way I
can tell when that task was done. If the check mark is unchecked the
second cell needs to be cleared out if a date was there already.

If you can help me with both how to create the check box and how to
attach the code to it to do the above it will be great.

Thanks.


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 02:53 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com