這是我的代碼。最後我得到了424錯誤。從我所瞭解的情況來看,我不需要這件作品的對象,所以我很困惑,爲什麼我得到這個錯誤。424對象未找到
編輯:我在最後一行得到的錯誤。
「工作表(」 工作表Sheet 「)。範圍(」 B1 「)。PasteSpecial.Values」
我給SrchRng作爲範圍,並且也是值。調試器中仍強調同一行。
Dim a As Range
Dim fd As FileDialog
Dim oFD As Variant
Dim AmazonFile As String
Dim Freight As Range
Dim OrderNo As Range
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.ButtonName = "Select"
.AllowMultiSelect = False
.Filters.Add "Amazon File", "*.csv", 1
.Title = "Choose Text File"
.InitialView = msoFileDialogViewDetails
.Show
For Each oFD In .SelectedItems
AmazonFile = oFD
Next oFD
On Error GoTo 0
End With
MsgBox AmazonFile
Set fd = Nothing
Workbooks.Open (AmazonFile)
Dim myString As String
Dim SrchRng
Do
Set a = SrchRng.Find("Carrier - Fee", LookIn:=xlValues)
If Not a Is Nothing Then a.EntireColumn.Copy
Loop While a Is Nothing
ActiveWorkbook.Sheets.Add
Worksheets("Sheet1").Range("B1").PasteSpecial.Values
'SrchRng'從未有一個值之前設置這一行:'Set a = SrchRng.Find(「Carrier - Fee」,LookIn:= xlValues)' – Comintern
'SrchRng'永遠不是initiali zed,並且您無法在未初始化的變量上調用Find方法。使用調試器。 –
感謝您的回覆。我仍然在最後一行發現錯誤:「工作表(」Sheet1「)。範圍(」B1「)。PasteSpecial.Values」通過調試器。 – CrazyKnows