+ Reply to Thread
Results 1 to 2 of 2

OptionButton Value to Active Cell

Hybrid View

  1. #1
    Registered User
    Join Date
    02-12-2007
    Location
    USA
    Posts
    27

    OptionButton Value to Active Cell

    Trying to click on option button on user form and have value added to active cell.
    My code not working.

     
    Private Sub UserForm1_Click()
     
        If OptionButton1 Then
            ActiveCell.Value = 1
        If OptionButton2 Then 
            ActiveCell.Value = 2
            
        
    End Sub

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 2019 on Win10 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: OptionButton Value to Active Cell

    Hi, dannac,

    right now you need to click on the UserForm itself instead of the optionbuttons. And you shhould receive an error message as End Ifs are missing.

    Please add the following code to your userform:
    Private Sub OptionButton1_Click()
    If OptionButton1 Then
      ActiveCell.Value = 1
    End If
    End Sub
    Private Sub OptionButton2_Click()
    If OptionButton2 Then
      ActiveCell.Value = 2
    End If
    End Sub
    HTH,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ 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