+ Reply to Thread
Results 1 to 2 of 2

Help with a option buttons located in a userform

  1. #1
    Registered User
    Join Date
    02-15-2006
    Posts
    6

    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

  2. #2
    Toppers
    Guest

    RE: 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
    >
    >


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1