Can I make a group of cells act like radio buttons?
Can I make a group of cells act like radio buttons?
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 10 of 10

Thread: Can I make a group of cells act like radio buttons?

  1. #1
    Board Regular
    Join Date
    Mar 2002
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    I'd like to program three cells so that if data is entered into any one of them, the other two become blank.

    Any help?

  2. #2
    Board Regular
    Join Date
    Feb 2002
    Location
    Richland, Washington
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Bobmc -
    Try something like:
    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Address = "$A$1" And
    Target.Formula <> "" Then [A2,A3].ClearContents
    If Target.Address = "$A$2" And Target.Formula <> "" Then [A1,A3].ClearContents
    If Target.Address = "$A$3" And Target.Formula <> "" Then [A1,A2].ClearContents
    End Sub

    Right-click your worksheet tab, select "View Code" and put the code there.
    Tom

    [ This Message was edited by: Tom Morales on 2002-03-14 12:05 ]

  3. #3
    Board Regular
    Join Date
    Mar 2002
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks for the reply!!!

    It came close to working...

    However, when I tab out of a given cell after entering anything <>"", the other cell that already has an entry doesn't 'CLEARCONTENTS' until I tab back into the cell I've just entered a value in.
    Also, the bottom-most of the three cells in question doesn't respond well...it wants to override entries into cells above it.

    Any more info on this is appreciated!

  4. #4
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    You could try a slight variation on Tom's code as below: -

    Private Sub Worksheet_Change(ByVal Target As Range)
    If Target.Address = "$A$1" Then [A2,A3].ClearContents
    If Target.Address = "$A$2" Then [A1,A3].ClearContents
    If Target.Address = "$A$3" Then [A1,A2].ClearContents
    End Sub

  5. #5
    Board Regular
    Join Date
    Mar 2002
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Again, close...

    This time, the top two of the three cells in question don't keep an entry. It erases itself as soon as I enter data.

    The bottom of the three cells holds its entry. But when I enter into one of the two cells above it, then hit tab, the bottom one doesn't go away and there's still no entry above.

    Hmmm.

  6. #6
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I'm confused now. You asked for code that would blank out two cells from a group of three, if an entry is made into the other cell. Mine does that, and I'm presuming Tom's does too. Could you reiterate exactly what you want?

  7. #7
    Board Regular
    Join Date
    Mar 2002
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    OK...I'M GETTING CLOSER!!!

    Here's the deal...

    Instead of the code header being SELECTION_CHANGE, I made it simply CHANGE. That solves the problem of entries not sticking. Now, here's the last little bug...
    If there's an entry in the bottom of the three cells, and I put an entry into the middle cell, the bottom cell keeps its entry rather than disappearing. Everything else works!

    Any last suggestions?

    Thanks.

  8. #8
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hmmm. My code works fine for me, whenever an entry is made in any of the cells the other two are blanked regardless of where the entry is made. Also, it already is using the Change event rather than SelectionChange. Copy and paste the code I gave you above into your worksheet and try that.

  9. #9
    Board Regular
    Join Date
    Mar 2002
    Posts
    142
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    MY BAD...

    Found a letter that was off. Sorry for the confusion...and...

    THANK YOU FOR YOUR WISDOM!! IT WORKS GREAT!

  10. #10
    MrExcel MVP
    Join Date
    Feb 2002
    Location
    Sunny, spring-like Hull
    Posts
    3,339
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Hehe, phew . Good luck with the rest .

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com