这是我的代码。我在最后得到了424错误。根据我的理解,我不需要该作品的对象,所以我很困惑为什么我会收到这个错误。
编辑:我在最后一行收到错误。
"工作表("工作表Sheet&#34)范围内。(" B1&#34)。PasteSpecial.Values"
我已将SrchRng作为Range并给出了值。在调试器中突出显示相同的行。
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
答案 0 :(得分:3)
问题在于PasteSpecial方法不是对象
更改此行
Worksheets("Sheet1").Range("B1").PasteSpecial.Values
到这一行
Worksheets("Sheet1").Range("B1").PasteSpecial xlPasteValues