Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Determining a combo box by code

I have a pivot table that can move the location of a combo box depending on
how many rows it returns. Is there any way to determine which cell the combo
box is in.
Something like:
For x = to beginRange to EndRange
if range("C:6") is Combo then ....

Thanks

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Determining a combo box by code

It might be easier to look at the combobox and find out where it is.

If the combobox is from the control toolbox toolbar:
msgbox worksheets("sheet2").oleobjects("combobox1").tople ftcell.address

If the combobox (AKA DropDown) is from the Forms toolbar:
msgbox worksheets("sheet2").dropdowns("drop down 1").topleftcell.address

Alan Davis wrote:

I have a pivot table that can move the location of a combo box depending on
how many rows it returns. Is there any way to determine which cell the combo
box is in.
Something like:
For x = to beginRange to EndRange
if range("C:6") is Combo then ....

Thanks


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Determining a combo box by code

Thanks Dave,

My problem is that this combo box is on a pivot table. I'm not sure if I can
refer to the pivot table cell and get the cell address. There are a bunch of
comb boxes (which are dimension filters) to choose from.

"Dave Peterson" wrote:

It might be easier to look at the combobox and find out where it is.

If the combobox is from the control toolbox toolbar:
msgbox worksheets("sheet2").oleobjects("combobox1").tople ftcell.address

If the combobox (AKA DropDown) is from the Forms toolbar:
msgbox worksheets("sheet2").dropdowns("drop down 1").topleftcell.address

Alan Davis wrote:

I have a pivot table that can move the location of a combo box depending on
how many rows it returns. Is there any way to determine which cell the combo
box is in.
Something like:
For x = to beginRange to EndRange
if range("C:6") is Combo then ....

Thanks


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,758
Default Determining a combo box by code

I'm not quite sure I understand, but you could cycle through all the comboboxes
and check to see if it is in C6.

Option Explicit
Sub testme()
Dim OLEObj As OLEObject
Dim FoundIt As Boolean

FoundIt = False
With Worksheets("sheet1")
For Each OLEObj In .OLEObjects
If TypeOf OLEObj.Object Is MSForms.ComboBox Then
If Intersect(OLEObj.TopLeftCell, .Range("c6")) Is Nothing Then
'keep looking
Else
FoundIt = True
Exit For
End If
End If
Next OLEObj
End With
If FoundIt = True Then
MsgBox FoundIt & vbLf & OLEObj.Name
Else
MsgBox "not found in C6!"
End If
End Sub

Alan Davis wrote:

Thanks Dave,

My problem is that this combo box is on a pivot table. I'm not sure if I can
refer to the pivot table cell and get the cell address. There are a bunch of
comb boxes (which are dimension filters) to choose from.

"Dave Peterson" wrote:

It might be easier to look at the combobox and find out where it is.

If the combobox is from the control toolbox toolbar:
msgbox worksheets("sheet2").oleobjects("combobox1").tople ftcell.address

If the combobox (AKA DropDown) is from the Forms toolbar:
msgbox worksheets("sheet2").dropdowns("drop down 1").topleftcell.address

Alan Davis wrote:

I have a pivot table that can move the location of a combo box depending on
how many rows it returns. Is there any way to determine which cell the combo
box is in.
Something like:
For x = to beginRange to EndRange
if range("C:6") is Combo then ....

Thanks


--

Dave Peterson


--

Dave Peterson
Reply
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
Combo Box Code Neil Pearce Excel Discussion (Misc queries) 3 January 5th 09 04:20 PM
Combo Box Code... younathan[_3_] Excel Programming 0 October 19th 04 01:46 PM
Combo Box Code... younathan[_2_] Excel Programming 0 October 19th 04 01:20 PM
Combo Box code Alex Excel Programming 3 June 21st 04 08:27 PM
VBA and determining which sheet the code is running under jake Excel Programming 2 April 28th 04 04:43 PM


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

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

About Us

"It's about Microsoft Excel"