LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
Joe Joe is offline
external usenet poster
 
Posts: 476
Default Add a combobox to an Excel spreadsheet and reference value in

If it matters, I'm using Office 2003

In the Visual Basic Project Window, I've placed the code in
VBAProject.Microsoft Excel Objects.Sheet1
VBAProject.Microsoft Excel Objects.ThisWorkbook
VBAProject.Modules.Module1
and am not able to get the code to work in any of these contexts.

The only thing I can think of is that what I'm typing in the Name Box for
the combobox is not exactly the object's name.
Is there any way in the Visual Basic watch window to see a list of the
objects on the Sheet, or what is the way to ensure the product's name is set
to what you specify?

Also, if you are willing to look at the spreadsheet, please email me at


Thanks,
Joe


"Tom Ogilvy" wrote:

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








 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ComboBox AddItem code to reference cells in a Range HBC_MT Excel Discussion (Misc queries) 0 February 26th 09 04:05 PM
How To Reference What Is In A ComboBox In A Cell Formulas??? Minitman Excel Worksheet Functions 4 March 25th 08 06:18 PM
How do I copy a combobox to many cells with relative reference? Levc Excel Discussion (Misc queries) 1 November 21st 07 06:58 PM
how to give the source value for a combobox on excel spreadsheet Jithu Excel Discussion (Misc queries) 2 May 29th 07 12:50 PM
unprotecting a combobox in your spreadsheet [email protected] Excel Programming 0 October 29th 03 05:53 PM


All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"