我正在尝试使用代码搜索所有工作簿,如果找到正在搜索的内容,它会将整行复制并粘贴到用户窗体中的列表框中。
我们订购了很多零件,我们想搜索一下该零件上次订购的时间。这次搜索将会提取出该信息。
下面的代码给了我一个错误消息,我不知道为什么。OBJECT DOESN’T SUPPORT THIS PROPERTY OR METHOD
当我运行代码时,粗体部分被突出显示。
有人可以帮忙吗?
Option Explicit
Private Sub CommandButton1_Click()
Dim wb1 As Workbook, wb2 As Workbook
Set wb1 = ThisWorkbook
Dim ws As Worksheet
Dim sPath As String
Dim sfile As String
Dim C As Range
sPath = "\\192.168.1.4\ET_Documents\Shared Documents\Inventory Transactions\TRANSACTIONS AS OF 11-3-2017\"
sfile = Dir(sPath & "*.xls*")
Application.ScreenUpdating = False
Set ws = Sheet1
ListBox1 = 0
Do While sfile <> ""
Set wb2 = Workbooks.Open(sPath & sfile)
With ListBox1
For Each C In wb2.Columns("b8:b15") ' THIS IS THE HIGHLIGHTED LINE
If C = TextBox1.Value Then
With C.EntireRow
ListBox1.AddItem
End With
End If
Next
End With
wb2.Close False
sfile = Dir()
Loop
Application.ScreenUpdating = True
End Sub