1
錯誤類型不匹配上以下行如何刪除通過在頭列名
vMatch = Application.Match(vHeaders(i), Sheets(Sht).Rows(lColumn), 0)
當調試,代碼表明vMatch = Empty
我缺少什麼?
Sub TestArray()
Dim vHeaders() As Variant
Dim vMatch As Variant
Dim i As Long
Dim Sht As Worksheet
Dim lColumn As Long
Set Sht = ActiveWorkbook.Sheets("Data")
lColumn = Sht.UsedRange.Columns.Count
vHeaders = Array("Branch", "Account#", "Route Name", "Driver Number", _
"Reference2", "Reference3", "Stop Number", "Phone", "Delivery Time", _
"Stop Close Time", "POD Contact Name", "Latitude", "Longitude", _
"Status", "Service", "ASN Create Date", "ASN Date", "StopID", _
"Load Scan", "Delivery Scan", "Exception", "Exception Time")
For i = LBound(vHeaders) To UBound(vHeaders) Step 1
vMatch = Application.Match(vHeaders(i), Sheets(Sht).Rows(lColumn), 0)
If IsNumeric(vMatch) Then Sheets(Sht).Columns(vMatch).delete
Next i
End Sub