Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / March 2008

Tip: Looking for answers? Try searching our database.

Code to insert check mark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jmcclain - 13 Mar 2008 14:27 GMT
I found the following code in a post from 2005.  I tried to follow the
instructions.  I pasted the code in the view code and exited back to EXCEL.  

i am trying to allow a user to click column D, E, and F and have EXCEL
automatically insert a check mark.

Am I on the right track?  Can someone outline the process to "activate" this
code so it will work?

Thanks again

Jon
jmcclain - 13 Mar 2008 14:30 GMT
Sorry,  here is the code.

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 Then
If Len(Trim(Target.Value)) = 0 Then
 Target.Value = Chr(252)
 Target.Font.Name = "Wingdings"
 Target.Font.Size = 10
Else
 Target.ClearContents
End If
End If
End Sub

> I found the following code in a post from 2005.  I tried to follow the
> instructions.  I pasted the code in the view code and exited back to EXCEL.  
[quoted text clipped - 8 lines]
>
> Jon
Bob Phillips - 13 Mar 2008 14:45 GMT
Try this alternative

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "D:E" '<=== change to suit

   On Error GoTo err_handler
   Application.EnableEvents = False
   If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
       With Target
           .Font.Name = "Marlett"
           Select Case .Value
               Case "":    .Value = "a"
               Case "a":   .Value = ""
           End Select
           me.cells(.row,"C").select
       End With
   End If
err_handler:
   Application.EnableEvents = True
End Sub

This is worksheet event code, which means that it needs to be
placed in the appropriate worksheet code module, not a standard
code module. To do this, right-click on the sheet tab, select
the View Code option from the menu, and paste the code in.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Sorry,  here is the code.
>
[quoted text clipped - 25 lines]
>>
>> Jon
jmcclain - 13 Mar 2008 15:31 GMT
Thanks Bob,

I have pasted it worksheet code module.  Does it have to be someone
"activated"?

I changed the column range to D:F, but nothing happens when I click cell D4.

Can you help?

Thanks

> Try this alternative
>
[quoted text clipped - 51 lines]
> >>
> >> Jon
Bob Phillips - 13 Mar 2008 18:12 GMT
No activation is required, it runs fine in those columns if you paste into
the worksheet code module.

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Thanks Bob,
>
[quoted text clipped - 64 lines]
>> >>
>> >> Jon
jmcclain - 13 Mar 2008 18:45 GMT
Bob,

Thanks - got it to work.  Had to exit and re-open the file.

Is there a way to "format" the check mark.  Center it?  Make it bigger?  Bold?

Agains...thanks

> No activation is required, it runs fine in those columns if you paste into
> the worksheet code module.
[quoted text clipped - 67 lines]
> >> >>
> >> >> Jon
Bob Phillips - 13 Mar 2008 18:59 GMT
All 3.

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Const WS_RANGE As String = "D:F" '<=== change to suit

   On Error GoTo err_handler
   Application.EnableEvents = False
   If Not Application.Intersect(Target, Range(WS_RANGE)) Is Nothing Then
       With Target
           .Font.Name = "Marlett"
           Select Case .Value
               Case "":    .Value = "a"
               Case "a":   .Value = ""
           End Select
           .HorizontalAlignment = xlCenter
           .Font.Size = 14
           .Font.Bold = True
           Me.Cells(.Row, "C").Select
       End With
   End If
err_handler:
   Application.EnableEvents = True
End Sub

Signature

---
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

> Bob,
>
[quoted text clipped - 82 lines]
>> >> >>
>> >> >> Jon
jmcclain - 13 Mar 2008 21:24 GMT
Thanks very much...it worked great

> All 3.
>
[quoted text clipped - 106 lines]
> >> >> >>
> >> >> >> Jon
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.