asyamonique
Well-known Member
- Joined
- Jan 29, 2008
- Messages
- 1,286
- Office Version
- 2013
- Platform
- Windows
Good Day,
Below code is running at userform but on worksheet module its not running...
What would be the reason.
I simply put on worksheet 2 combo and 1 listbox
Is there anything that I need to add?
Below code is running at userform but on worksheet module its not running...
What would be the reason.
I simply put on worksheet 2 combo and 1 listbox
Is there anything that I need to add?
Code:
Private Sub CommandButton1_Click()
Dim r As Long, Ac As Long, c As Long
If ComboBox1.Value <> -1 And ComboBox2.Value <> -1 Then
ListBox1.Clear
With Worksheets("Reports").Range("A1:A500")
ReDim Ray(1 To .Count, 1 To 9)
For r = 1 To .Rows.Count
With ListBox1
.ColumnCount = 9
.ColumnWidths = "0;0;100;100;100;100;100;100;0"
End With
If ComboBox1.Value = .Cells(r, 1).Value And ComboBox2.Value = .Cells(r, 2).Value Then
c = c + 1
For Ac = 1 To 9
Ray(c, Ac) = .Cells(r, Ac)
Next Ac
End If
Next r
End With
End If
ListBox1.List = Ray
End Sub