VBA错误13与查找代码

时间:2018-06-20 14:56:51

标签: vba

我遇到类型不匹配的问题,在我的表中该值是常规值,因为它是从数据透视表中复制并粘贴值

在这里抛出错误:

Set mf = Columns("F").Find(What:=ONE, After:=ActiveCell, LookIn:= _
xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
xlNext, MatchCase:=False, SearchFormat:=False)



Dim ONE As String

Worksheets("Chart").Activate
Columns("A:B").Select
Selection.Copy
Range("F1").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
Range("F2").Select
Application.CutCopyMode = False
Selection.Copy
ONE = Cells(2, "F").Value
Sheets("Paste Data Table").Select

Set mf = Columns("F").Find(What:=ONE, After:=ActiveCell, LookIn:= _
    xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
    xlNext, MatchCase:=False, SearchFormat:=False)

ActiveCell.EntireRow.Select

Application.CutCopyMode = False
Selection.Copy
Sheets("Top 5 Breakdown").Select

Sheets("Top 5 Breakdown").Select
Range("A2").Select
ActiveSheet.Paste
Worksheets("Paste Data Table").Activate
Range("A2").Select
Application.CutCopyMode = False

1 个答案:

答案 0 :(得分:2)

导致此Find方法出错的原因是:

After:=ActiveCell

在这种情况下,无法搜索不在搜索范围F列中的单元格。您的活动单元格不在F列中。