Results 1 to 5 of 5

Radio Buttons in cells without control toolbox

Threaded View

  1. #1
    Registered User
    Join Date
    09-12-2009
    Location
    Las Vegas, Nevada
    MS-Off Ver
    Excel 2003
    Posts
    7

    Radio Buttons in cells without control toolbox

    Instead of using radio buttons from the control toolbox, I have created a radio button type of group within 3 cells the code is as follows:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then [C1,E1].ClearContents
    If Target.Address = "$C$1" Then [A1,E1].ClearContents
    If Target.Address = "$E$1" Then [A1,C1].ClearContents
    End Sub 
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Target.Cells.Count > 1 Then Exit Sub
    
            If Not Intersect(Target, Range("A1, C1, E1 ")) Is Nothing Then
    
                Target.Font.Name = "Webdings"
    
                    If Target = vbNullString Then
    
                        Target = "g"
    
                    Else
    
                        Target = vbNullString
    
                    End If
    ‘End Code
    
    What this does is puts an “g” in the cell that is clicked on and clears the other two cells. What I want it to do instead is to put a “c” in the cells that are cleared. With the Webdings font this makes the cells with a "g" in them look like a filled checked box and the cells with a "c" in them an unfilled checked box. 
    
    I have tried the following code and it works with an exception. The cell that you want to select has to be selected twice (clicked in once, clicked out of once, then click in again).
    
    ‘Begin Code
    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then [C1,E1] = "c"
    If Target.Address = "$C$1" Then [A1,E1] = "c"
    If Target.Address = "$E$1" Then [A1,C1] = "c"
    End Sub 
    
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    
        If Target.Cells.Count > 1 Then Exit Sub
    
            If Not Intersect(Target, Range("A1, C1, E1 ")) Is Nothing Then
    
                Target.Font.Name = "Webdings"
    
                    If Target = vbNullString Then
    
                        Target = "g"
    
                    Else
    
                        Target = vbNullString
    
                    End If
    Any help is greatly appreciated.
    Last edited by Leith Ross; 09-13-2009 at 02:56 PM. Reason: Added Code Tags

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1