![]() |
Add a combobox to an Excel spreadsheet and reference value in VBA
I have the combox in my spreadsheet and have the VBA code running when there
is a change to the value, but I don't know how to refer to the combobox to get the currently selected value |
Add a combobox to an Excel spreadsheet and reference value in VBA
worksheets("Sheet1").OleObjects("Combobox1").Objec t.Value
or if you are in the code module for sheet1 (the sheet where the combobox is located) combobox1.Value -- Regards, Tom Ogilvy "Joe" wrote in message ... I have the combox in my spreadsheet and have the VBA code running when there is a change to the value, but I don't know how to refer to the combobox to get the currently selected value |
Add a combobox to an Excel spreadsheet and reference value in
My code is in the Modules section tied to the spreadsheet where I have the
function ComboBox1_Change() Neither of the syntaxes you listed work in this context, nor does ActiveSheet.OLEObjects("ComboBox1").Object.Value Any more ideas? "Tom Ogilvy" wrote: worksheets("Sheet1").OleObjects("Combobox1").Objec t.Value or if you are in the code module for sheet1 (the sheet where the combobox is located) combobox1.Value -- Regards, Tom Ogilvy "Joe" wrote in message ... I have the combox in my spreadsheet and have the VBA code running when there is a change to the value, but I don't know how to refer to the combobox to get the currently selected value |
Add a combobox to an Excel spreadsheet and reference value in
Private Sub ComboBox1_Click()
val1 = _ Worksheets("Sheet1").OLEObjects( _ "Combobox1").Object.Value val2 = ComboBox1.Value MsgBox val1 & " - " & val2 End Sub worked fine for me. Not sure what you are talking about. From your description, you may have your code in wrong place, but it is too ambiguous to tell. If you right click on the sheet tab with the combobox and select view code, that is where the code should be. -- Regards, Tom Ogilvy "Joe" wrote in message ... My code is in the Modules section tied to the spreadsheet where I have the function ComboBox1_Change() Neither of the syntaxes you listed work in this context, nor does ActiveSheet.OLEObjects("ComboBox1").Object.Value Any more ideas? "Tom Ogilvy" wrote: worksheets("Sheet1").OleObjects("Combobox1").Objec t.Value or if you are in the code module for sheet1 (the sheet where the combobox is located) combobox1.Value -- Regards, Tom Ogilvy "Joe" wrote in message ... I have the combox in my spreadsheet and have the VBA code running when there is a change to the value, but I don't know how to refer to the combobox to get the currently selected value |
All times are GMT +1. The time now is 12:18 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com