Wierd Listbox problem

  • Thread starter Thread starter Gunner
  • Start date Start date
G

Gunner

Hi,

I have a userform with a listbox I fill with content of a
range. Works fine. But I found out that some of the rows
are NOT needed in the listbox. I therefore made the range
without this rows,like this:
=Tankoversikt!$B$5:$P$12;Tankoversikt!
$B$14:$P$27;Tankoversikt!$B$29:$P$31
(Obviously not row 13 and 28

But when I run the makro I get a wierd error, and are
being kicked out.

Here is the code to fill the listbox:
UserForm6.LBTankRes.RowSource = "Tankoversikt!
LuftgassLager"

Maybe something like this works? If the content of
range"luftgassLager" column A is anything except integer,
do not fill with that row...

Does anyone have a clue?
Anyhelp is appreciated from this guy.

MR.G
 
List boxes generally require a contiguous range. However, you might
want to use a macro with the additem property. See below for ideas:

Set theBox = ActiveSheet.Shapes("List Box 4")
theBox.ControlFormat.RemoveAllItems
For x = 7 To 17
CheckNum = IsNumeric(Cells(x, 5).Value)
If CheckNum Then
If Int(Cells(x, 5).Value) = Cells(x, 5).Value Then
theBox.ControlFormat.AddItem Cells(x, 5).Value
End If
End If
Next
 
List boxes generally require a contiguous range. However, you might
want to use a macro with the additem property. See below for ideas:

Set theBox = ActiveSheet.Shapes("List Box 4")
theBox.ControlFormat.RemoveAllItems
For x = 7 To 17
CheckNum = IsNumeric(Cells(x, 5).Value)
If CheckNum Then
If Int(Cells(x, 5).Value) = Cells(x, 5).Value Then
theBox.ControlFormat.AddItem Cells(x, 5).Value
End If
End If
Next
 
Back
Top