More Problems with CBO's

  • Thread starter mtm4300 via OfficeKB.com
  • Start date
M

mtm4300 via OfficeKB.com

I have a worksheet that displays Example Problems. The worksheet has hundreds
of rows of text and text boxes. I created a combobox that lists each Example
Problem so the user can click on the problem he/she wants and the macro will
take them to that problem (a certain row in the worksheet). To help the user
get back to the top, I created Label names "^top" at the end of each Example
Problem. This Label takes the user back to the top of the worksheet (A1).
However, when I do this, the combobox remains with the item the user last
clicked on. I would like for the combobox to display the first Example
Problem because the first Example Problem begins on cell A1. I also have
protected the sheet., so if I delete the box I get an error. I tried
unprotect/protect in my macro, but I would rather be able to change the
combobox without deleting it. The code for my combobox is:

Private Sub ComboBox1()
With Worksheets(45).Shapes.AddFormControl(xlDropDown, _
Left:=440, Top:=47, Width:=240, Height:=15)
.ControlFormat.DropDownLines = 9
.ControlFormat.AddItem "Example 1: Method 1, Circular Corrugated Pipe", 1
.ControlFormat.AddItem "Example 2: Method 1, Deformed Smooth-Interior
Pipe", 2
.ControlFormat.AddItem "Example 3: Method 1, Circular Smooth-Interior
Pipe", 3
.ControlFormat.AddItem "Example 4: Method 2, Circular Corrugated Pipe", 4
.ControlFormat.AddItem "Example 5: Method 2, Circular Corrugated Pipe
(SPM)", 5
.ControlFormat.AddItem "Example 6: Method 2, Deformed Corrugated Pipe", 6
.ControlFormat.AddItem "Example 7: Method 3, Circular Corrugated Pipe", 7
.ControlFormat.AddItem "Example 8: Method 3, Deformed Corrugated Pipe
(SPAA)", 8
.ControlFormat.AddItem "Example 9: Method 3, Deformed Corrugated Pipe
(SPS)", 9
.Name = "ComboBox1"
.OnAction = "ComboBox1_Change"
End With
End Sub

The code for the "^top" button is simply a Sub with Range("A1").Select

Any help would be greatly appreciated.
 
T

Tom Ogilvy

Your ^top macro should include a line of code like

activesheet.dropdowns("Combobox1").listIndex = 1
Range("A1").Select
 
M

mtm4300 via OfficeKB.com

When I use this code I get a Run-Time Error '1004'

It reads " Unable to get Dropdowns Property of The Worksheet Class"

any ideas?
Thank You.

Tom said:
Your ^top macro should include a line of code like

activesheet.dropdowns("Combobox1").listIndex = 1
Range("A1").Select
I have a worksheet that displays Example Problems. The worksheet has hundreds
of rows of text and text boxes. I created a combobox that lists each Example
[quoted text clipped - 35 lines]
Any help would be greatly appreciated.
 
T

Tom Ogilvy

I ran your code and my event code looked like this:

Sub ComboBox1_Change()
ActiveSheet.DropDowns("Combobox1").ListIndex = 1
Range("A1").Select
End Sub

worked fine for me.

I ran it in a separate routine and it again ran perfectly.
Sub AAA()
ActiveSheet.DropDowns("Combobox1").ListIndex = 1
Range("A1").Select

End Sub

It appears to be some implementation problem on your part. Maybe you have
put it in a sheet module or something - I can't say. But there is nothing
wrong with the suggestion.

--
Regards,
Tom Ogilvy



mtm4300 via OfficeKB.com said:
When I use this code I get a Run-Time Error '1004'

It reads " Unable to get Dropdowns Property of The Worksheet Class"

any ideas?
Thank You.

Tom said:
Your ^top macro should include a line of code like

activesheet.dropdowns("Combobox1").listIndex = 1
Range("A1").Select
I have a worksheet that displays Example Problems. The worksheet has hundreds
of rows of text and text boxes. I created a combobox that lists each
Example
[quoted text clipped - 35 lines]
Any help would be greatly appreciated.
 
M

mtm4300 via OfficeKB.com

I did have my "^top" Subs in the worksheet. I have placed the Sub in a Module
and I do not get an error anymore. However, when I click on the "^top" label
nothing happens. What am I doing wrong? Thanks in advance!

Tom said:
I ran your code and my event code looked like this:

Sub ComboBox1_Change()
ActiveSheet.DropDowns("Combobox1").ListIndex = 1
Range("A1").Select
End Sub

worked fine for me.

I ran it in a separate routine and it again ran perfectly.
Sub AAA()
ActiveSheet.DropDowns("Combobox1").ListIndex = 1
Range("A1").Select

End Sub

It appears to be some implementation problem on your part. Maybe you have
put it in a sheet module or something - I can't say. But there is nothing
wrong with the suggestion.
When I use this code I get a Run-Time Error '1004'
[quoted text clipped - 13 lines]
 
M

mtm4300 via OfficeKB.com

Im sorry. An error message did occur when I ran the macro in a module. I dont
know what to do with this. It seems that it should work but its not. Does
anyone have any ideas?
I did have my "^top" Subs in the worksheet. I have placed the Sub in a Module
and I do not get an error anymore. However, when I click on the "^top" label
nothing happens. What am I doing wrong? Thanks in advance!
I ran your code and my event code looked like this:
[quoted text clipped - 21 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top