Radio button use in form

J

John Galt

I guess this isn't as simple as I had hoped. Excel 2003 - I have a form that
has a space for Primary residence address and another for "subject Property",
I wanted to use a radio button named "same" to allow users to click it if the
address info should just be copied from Primary to corresponding cells in
Subject (i.e. Address, City, ZIP). And I of course want them to enter the
Subject Address in if it is indeed different, and I assumed that they would
need to uncheck the "same" radio button... Thank you in advance for any help
 
S

Shane Devenshire

Hi,

It might be easier to use a checkbox. Because if you only have one option
button you can't turn it off easily, you would want a second option button in
that case as part of a group.

Is this on a UserForm in VBA or a form in the spreadsheet? In the case of a
option button in the spreadsheet you can use a formula approach, but on a VBA
form you will need to use VBA. You might also choose to use VBA in the
spreadsheet because it is a little cleaner. On the vba form you will use code
attached to the on Click or Change procedure of the option button, similarly
to the checkbox.

For a spreadsheet check box the code might look like this

Private Sub CheckBox1_Click()
If Me.CheckBox1 = True Then
[A5] = [A1]
Else
[A5].ClearContents
End If
End Sub
 
J

John Galt

Hello Shane,
Sorry for long delay. I tried what you had below and it seemed to have a
problem with the "Me" thing, so i copied from another Macro and tried this:

Sub SameAddressBox_Click()
If SameAddressBox = True Then
[SubjectAddress] = [E9:L9]
Else
[SubjectAddress].clearcontents
End If
End Sub

I also tried it with the clearcontents line but it told me it couldn't
change a merged cells contents? So I took that out and tried it with out that
at all. I figured I was just in over my head and should get on here and
follow up. Obviously none of it seems to be working? Where'd I go wrong?

"SubjectAddress" is what I named the merged cells E15:L15

Shane Devenshire said:
Hi,

It might be easier to use a checkbox. Because if you only have one option
button you can't turn it off easily, you would want a second option button in
that case as part of a group.

Is this on a UserForm in VBA or a form in the spreadsheet? In the case of a
option button in the spreadsheet you can use a formula approach, but on a VBA
form you will need to use VBA. You might also choose to use VBA in the
spreadsheet because it is a little cleaner. On the vba form you will use code
attached to the on Click or Change procedure of the option button, similarly
to the checkbox.

For a spreadsheet check box the code might look like this

Private Sub CheckBox1_Click()
If Me.CheckBox1 = True Then
[A5] = [A1]
Else
[A5].ClearContents
End If
End Sub



--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


John Galt said:
I guess this isn't as simple as I had hoped. Excel 2003 - I have a form that
has a space for Primary residence address and another for "subject Property",
I wanted to use a radio button named "same" to allow users to click it if the
address info should just be copied from Primary to corresponding cells in
Subject (i.e. Address, City, ZIP). And I of course want them to enter the
Subject Address in if it is indeed different, and I assumed that they would
need to uncheck the "same" radio button... Thank you in advance for any help
 

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