+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    11-09-2009
    Location
    Cologne, Germany
    MS-Off Ver
    Excel 2007
    Posts
    1

    Using information in Combobox in VBA

    hi everyone,

    I want to use information ticked in a combobox in my excel spreadsheet using VBA. I.e., if you choose "add" and start the macro then vba add two or more numbers. If you choose "multiply" in the combobox then vba multiply them etc.
    Can someone please tell me how to solve this with vba? I would be very thankful!
    Cheers,
    Rafael

  2. #2
    Forum Guru rwgrietveld's Avatar
    Join Date
    09-02-2008
    Location
    Netherlands
    MS-Off Ver
    XL 2007 / XL 2010
    Posts
    1,671

    Re: Using information in Combobox in VBA

    Can use this
    Code:
    Private Sub ComboBox1_Change()
      Select Case ComboBox1.Value
        Case "Multiply"
          TextBox3.Value = TextBox1.Value * TextBox2.Value
          TextBox4.Value = "*"
        Case "Divide"
          TextBox3.Value = TextBox1.Value / TextBox2.Value
          TextBox4.Value = "/"
        Case "Add"
          TextBox3.Value = TextBox1.Value + TextBox2.Value
          TextBox4.Value = "+"
        Case Else
        '
      End Select
    
    End Sub
    
    Private Sub Worksheet_Activate()
      ComboBox1.AddItem "Multiply"
      ComboBox1.AddItem "Divide"
      ComboBox1.AddItem "Add"
    End Sub
    Attached Files Attached Files
    Looking for great solutions but hate waiting?
    Seach this Forum through Google

    www.Google.com
    (e.g. +multiple +IF site:excelforum.com/excel-general/ )

    www.Google.com
    (e.g. +fill +combobox site:excelforum.com/excel-programming/ )

    Ave,
    Ricardo

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.2.0