Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
write to column A depending on which Radio button is selected.
Hi everyone,
I have 4 radio buttons on a worksheet named right, left, front, and back. I want Cells (selected.row, 1) to be given the value "right, left, front, or back" depending on the button selected but only if they type text in that row (in column B specifically) And if they erase the contents in row B then it will erase as well. Thanks |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
write to column A depending on which Radio button is selected.
I don't fool with controls in Excel much - some, not much - but it seems to
me that if you've already attached code to each button selection then each command just has to read something like this: If ActiveSheet.Cells(ActiveCell.Row, 2) < "" then ActiveCell = SelectedValue Something like that should set the value you want when the user clicks on one of your radio buttons. If you want to change A back to blank when the user deletes B, that takes a Change event; I've never written one but I gather it would look like this: Private Sub Worksheet_Change(ByVal ChgCell as Range) If ChgCell.Column = 2 And ChgCell.Value = "" Then ChgCell.Offset(0, -1) = "" End Sub I think this goes in the worksheet code, not in an additional module, so you don't have to check to be sure you're in the right worksheet too. But the only Change event applies to any cell in the Worksheet, so the same Sub has to be executed every time anyone types anything at all into the worksheet, and the sub has to see which cell was changed and react only in certain circumstances. --- "Jim" wrote: I have 4 radio buttons on a worksheet named right, left, front, and back. I want Cells (selected.row, 1) to be given the value "right, left, front, or back" depending on the button selected but only if they type text in that row (in column B specifically) And if they erase the contents in row B then it will erase as well. Thanks |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
write to column A depending on which Radio button is selected.
Thanks Bob, That is getting closer. I might be able to work with something
like this. But............... What if they first select the OptionButton "Right", Type some stuff so it placed "Right" in col A, Then Selected OptionButton "Left" and typed some more stuff and it placed "left" in col A? Any suggestions? thanks "Bob Bridges" wrote: I don't fool with controls in Excel much - some, not much - but it seems to me that if you've already attached code to each button selection then each command just has to read something like this: If ActiveSheet.Cells(ActiveCell.Row, 2) < "" then ActiveCell = SelectedValue Something like that should set the value you want when the user clicks on one of your radio buttons. If you want to change A back to blank when the user deletes B, that takes a Change event; I've never written one but I gather it would look like this: Private Sub Worksheet_Change(ByVal ChgCell as Range) If ChgCell.Column = 2 And ChgCell.Value = "" Then ChgCell.Offset(0, -1) = "" End Sub I think this goes in the worksheet code, not in an additional module, so you don't have to check to be sure you're in the right worksheet too. But the only Change event applies to any cell in the Worksheet, so the same Sub has to be executed every time anyone types anything at all into the worksheet, and the sub has to see which cell was changed and react only in certain circumstances. --- "Jim" wrote: I have 4 radio buttons on a worksheet named right, left, front, and back. I want Cells (selected.row, 1) to be given the value "right, left, front, or back" depending on the button selected but only if they type text in that row (in column B specifically) And if they erase the contents in row B then it will erase as well. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Change color of radio button caption if selected | Excel Programming | |||
Cell data depending on column selected. | Excel Programming | |||
How do I lock a radio button group if a N/A button is selected | Excel Discussion (Misc queries) | |||
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True | Excel Worksheet Functions | |||
Vb Application to locate a worksheet depending on the radio box selected | Excel Programming |