Results 1 to 5 of 5

Thread: Combobox VBA update value worksheet

  1. #1
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0

    Combobox VBA update value worksheet

    Hi all,

    How can i change a value in a cell using a combobox in VBA userform?

    I already created a group called scenario range ='INPUT ALG'!$D$34:$D$36

    How can i select it in the vba combobox and then update the value in the already existing combobox on the excelsheet.

  2. #2
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Hi

    Not sure what do you want.

    To get the selected value, try

    Code:
    Private Sub ComboBox1_Change()
        
        Dim lngIndex    As Long
        
        With Me.ComboBox1
            lngIndex = .ListIndex
            If Not lngIndex = -1 Then
                MsgBox .List(lngIndex)
            End If
        End With
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  3. #3
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    I cant upload the file as it is trusted, but i try to explain it:

    On worksheet dashboard i have on cell E1 a combobox that is listing 3 values. When changing the combobox value the data behind will change automatically. What i try to do is create a combobox in a userform VBA that is getting the values of the combobox in cell E1 and when picking one of those values updating the value of E1 with the selected value.

  4. #4
    Administrator Admin's Avatar
    Join Date
    Mar 2011
    Posts
    1,123
    Rep Power
    10
    Again not sure..

    Code:
    Private Sub ComboBox1_Change()
        
        Dim lngIndex    As Long
        
        With Me.ComboBox1
            lngIndex = .ListIndex
            If Not lngIndex = -1 Then
                [e1]= .List(lngIndex)
            End If
        End With
        
    End Sub
    Cheers !

    Excel Range to BBCode Table
    Use Social Networking Tools If You Like the Answers !

    Message to Cross Posters

    @ Home - Office 2010/2013/2016 on Win 10 (64 bit); @ Work - Office 2016 on Win 10 (64 bit)

  5. #5
    Junior Member
    Join Date
    Oct 2012
    Posts
    26
    Rep Power
    0
    Quote Originally Posted by Admin View Post
    Again not sure..

    Code:
    Private Sub ComboBox1_Change()
        
        Dim lngIndex    As Long
        
        With Me.ComboBox1
            lngIndex = .ListIndex
            If Not lngIndex = -1 Then
                [e1]= .List(lngIndex)
            End If
        End With
        
    End Sub
    Hi :D

    Thanks for your help, worked exactly how it should be .

    Private Sub ComboBox1_Change()

    Code:
        Dim lngIndex    As Long
        
        With Me.ComboBox1
            lngIndex = .ListIndex
            If Not lngIndex = -1 Then
                [DASHBOARD!C6]= .List(lngIndex)
            End If
        End With
        
    End Sub
    And i set the rowsource to Scenario.. works perfect.. Is there also a way to display the current value on loading the userform in the combobox?

Similar Threads

  1. Trim all Cells in a Worksheet - VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 6
    Last Post: 08-21-2015, 08:22 AM
  2. Combobox Not Working In Excel Workbook Shared Mode
    By peter renton in forum Excel Help
    Replies: 15
    Last Post: 06-03-2013, 01:25 PM
  3. Print Nth Worksheet To Mth Worksheet using VBA
    By Ryan_Bernal in forum Excel Help
    Replies: 2
    Last Post: 02-28-2013, 06:57 PM
  4. Replies: 2
    Last Post: 11-17-2011, 07:49 PM
  5. Sort Worksheet by Color VBA
    By Admin in forum Excel and VBA Tips and Tricks
    Replies: 0
    Last Post: 10-25-2011, 02:25 AM

Posting Permissions

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