Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 108
Default 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   Report Post  
Posted to microsoft.public.excel.programming
Jim Jim is offline
external usenet poster
 
Posts: 615
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Change color of radio button caption if selected HH[_4_] Excel Programming 5 April 7th 08 06:53 PM
Cell data depending on column selected. [email protected] Excel Programming 1 May 1st 06 10:54 AM
How do I lock a radio button group if a N/A button is selected worry a lot Excel Discussion (Misc queries) 2 May 21st 05 08:33 PM
VBA: Disable Frame and Radio Buttons based on Another Radio Button Being True Mcasteel Excel Worksheet Functions 2 October 29th 04 07:06 PM
Vb Application to locate a worksheet depending on the radio box selected Shawn[_7_] Excel Programming 1 July 7th 04 08:27 PM


All times are GMT +1. The time now is 04:25 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"