What is wrong with this code

Deloka

New Member
Joined
Sep 26, 2011
Messages
3
'Uses a loop to step through each cell in the new make list
'and adds each make to the combo box.
'If a value is blank, it is not added.
For Each cell In Worksheets("Data").Range("j4:j26")
If IsEmpty(cell) = False Then
cbomake.AddItem cell.Value
End If
Next cell

I keep getting an error on the line in red
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
When the error occurs, do you get a dialog box offering you a Debug button? If so, what is the error message displayed in the dialog box? Next, click the Debug button and execute this code line in the Immediate Window...

Code:
? Cell.Address
What gets printed out. Also, where is the ComboBox... on a worksheet or on a UserForm? If on a worksheet, where did you get it from... is it a Forms' ComboBox or an ActiveX ComboBox?
 
Upvote 0
This is the complete code.
I am using Control combo box

Private Sub cbocatalog_Change()
'Creates a string variable, Category, that stores the value of
'the Category selected by the user.
Dim Catalog As String

'Sets the Category variable to the category value selected by the user
Catalog = cbocatalog.Value

'Clears the filter criteria (row 2 in the Data worksheet).
Worksheets("Data").Range("A2:d2").Clear

'Sets the filter criteria based on the new selection.
'Don 't worry if the code looks complicated to you, just focus on the key parts:
'The range is where the formula will be written
'(i.e. in cell A2 on the Data worksheet)
'and the Category variable
Worksheets("Data").Range("A2").Formula = _
"=" & Chr(34) & "=" & Chr(34) & "&" & Chr(34) & Catalog & Chr(34)

'Clears the range where the results will be written
Worksheets("Data").Range("i3:l26").Clear

'Uses the Advanced Filter to create a unique set of make values that
'are linked to the selected category. Read the first part of the series,
'"Populating Cascading Combo Boxes Part1" for details
Worksheets("Data").Range("$A$3:$d$26").AdvancedFilter _
Action:=xlFilterCopy, _
criteriarange:=Worksheets("Data").Range("A1:d2"), _
CopyToRange:=Worksheets("Data").Range("i3"), _
Unique:=True

'Clears the contents of the Make combo box, and sets the selected value
'to nothing. This prepares it to be populated by the newly filtered
'set of values for make.
Make = cbomake.Value
Make = cbomake.Value = ""

'Uses a loop to step through each cell in the new make list
'and adds each make to the combo box.
'If a value is blank, it is not added.

End Sub
 
Upvote 0

Forum statistics

Threads
1,224,597
Messages
6,179,809
Members
452,944
Latest member
2558216095

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top