Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel-VBA: Getting the values from Form Controls

Embedded in the worksheet sheet1 I have a Form Control combo box named combobox_test and it has selected value x

in addition to that, i also have embbeded a button that when i press it i want it to take the value of combobox_test and place it in something.Rows(y). But i cant get it working and am getting a bit frustrated. Maybe you can point me in the right direction

Sub ButtonPressed_sample()
    Dim value As String

    Set putItRng = Range("theCells")        
    putItRng.Rows(1) = ActiveSheet.Shapes("combobox_test").Value        
End Sub

Any advise? Am an absolute beginner in VBA, so please be as detailed as you can. Thanks

like image 524
Carlos Avatar asked Nov 18 '10 21:11

Carlos


1 Answers

I'm not sure this is what you want, but it's a start. The Shape object doesn't have a Value property, which is the source of the error. There is a DropDown object that is deprecated, but still available.

Sub ButtonPressed_sample()

    Set putitrng = Range("theCells")
    putitrng.Rows(1) = ActiveSheet.DropDowns("combobox_test").value

End Sub
like image 165
Dick Kusleika Avatar answered Oct 19 '22 13:10

Dick Kusleika