Hello Guys,
I am getting ## Run-time error '424': Object required ## when executing the code below:
Thank for your help in advance.
Witek
I am getting ## Run-time error '424': Object required ## when executing the code below:
Code:
Private Sub CommandButton2_Click()
'Application.ScreenUpdating = False
Dim xlWB As Workbook
Dim xlWS As Worksheet
Set xlApp = New Excel.Application
pathfile = "Tracker.xlsx"
Set xlWB = xlApp.Workbooks.Open(pathfile)
Set xlWS = xlWB.Worksheets("2017")
Submitter = SubmitterBox.Value
'Loads values into listbox
ListBox1.ColumnCount = 2
ListBox1.Clear
Dim i As Long
Dim b As Long
Dim Lastrow As Long
Lastrow = xlWS.Cells(Rows.Count, "A").End(xlUp).Row
b = 0
For i = 2 To Lastrow
[COLOR=#FF0000] If Submitter = xlWB.Worksheets("2017").Range("B" & i).Value And xlWB.Worksheets("2017").Range("K" & i).Value = "Open" Then[/COLOR]
With ListBox1
.AddItem
.List(b, 0) = xlWS.Cells(i, 1).Value
.List(b, 1) = xlWS.Cells(i, 7).Value
b = b + 1
End With
End If
Next
'Application.ScreenUpdating = True
xlWB.Close SaveChanges:=True
xlApp.Quit
End Sub
Thank for your help in advance.
Witek