ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Help with a option buttons located in a userform (https://www.excelbanter.com/excel-programming/354747-help-option-buttons-located-userform.html)

mav93[_5_]

Help with a option buttons located in a userform
 

Hi everyone

I have two option buttons in user form1
I'm wondering what code I would need to use and where it would go
to link the that I have placed in to userform 1 to cell "A1" in
worksheet 'Material takeoff'

this is my first time with userforms and the properties and I'm just a
newbie at VBA

If option buttion 1 in the user form is selected then cell "A1" should
= 1
If option buttion 2 in the user form is selected then cell "A1" should
= 2
if neither are selected it should = 0 or blank
also the value in cell A1 to change before the userform is closed

Thanks in advance for any help


--
mav93
------------------------------------------------------------------------
mav93's Profile: http://www.excelforum.com/member.php...o&userid=31592
View this thread: http://www.excelforum.com/showthread...hreadid=517867


Toppers

Help with a option buttons located in a userform
 
Put this code in your userform (right click on Userform==view code and
copy/paste)

A1 (on Sheet2 in the example .. change to suit your needs ...) is set 0
when the form is loaded.

Optionbutton is TRUE when selected which is numerically -1: hence muliples
of -1 and -2 to get 1 & 2 in A1

HTH

Private Sub OptionButton1_Click()
Worksheets("Sheet2").Range("A1") = OptionButton1.Value * -1
End Sub
Private Sub OptionButton2_Click()
Worksheets("Sheet2").Range("A1") = OptionButton2.Value * -2
End Sub
Private Sub UserForm_Initialize()
Worksheets("Sheet2").Range("A1") = 0 '<=== set A1 to zero
End Sub

"mav93" wrote:


Hi everyone

I have two option buttons in user form1
I'm wondering what code I would need to use and where it would go
to link the that I have placed in to userform 1 to cell "A1" in
worksheet 'Material takeoff'

this is my first time with userforms and the properties and I'm just a
newbie at VBA

If option buttion 1 in the user form is selected then cell "A1" should
= 1
If option buttion 2 in the user form is selected then cell "A1" should
= 2
if neither are selected it should = 0 or blank
also the value in cell A1 to change before the userform is closed

Thanks in advance for any help


--
mav93
------------------------------------------------------------------------
mav93's Profile: http://www.excelforum.com/member.php...o&userid=31592
View this thread: http://www.excelforum.com/showthread...hreadid=517867




All times are GMT +1. The time now is 08:23 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com