write to column A depending on which Radio button is selected.

J

Jim

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
 
B

Bob Bridges

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.
 
J

Jim

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top