-1

我收到以下代码的类型不匹配错误。为什么?

If (Range("C:C").Find(What:=last_received, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False)) is Nothing Then
        tic = 1
    End If

此外,我创建了一个 Range 变量并将其设置为注意并使用以下代码,但仍然出现相同的错误:

If (Range("C:C").Find(What:=last_received, After:=ActiveCell, LookIn:= _
        xlFormulas, LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:= _
        xlNext, MatchCase:=False, SearchFormat:=False)) = rr Then
        tic = 1
    End If
4

2 回答 2

0

(代表 OP,murugan_kotheesan 发布)

感谢我。以下是最终的工作代码

    Sheets("Extract -prev").Select
    Application.Goto Reference:="R1C3"        'taking last received ticket
    Selection.End(xlDown).Select
    last_received = ActiveCell.Value
    Selection.Copy
    Sheets("Calc").Select
    Application.Goto Reference:="Yesterday_last_received"
    ActiveSheet.Paste

'----------changing last received ticket if it is not available in todays ticket

    Sheets("Extract").Select
    Range("A1").Select
    Worksheets("Extract").AutoFilterMode = False
    Selection.AutoFilter

   lr = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
   For Each rr In Range("C1:C" & lr)
       If rr Like last_received Then
            tic = 0
       End If
   Next

    Do While (tic <> 0)
        Sheets("Extract -prev").Select
        Selection.Offset(-1, 0).Select
        last_received = ActiveCell.Value

        Sheets("Extract").Select
        Range("A1").Select
        Worksheets("Extract").AutoFilterMode = False
        Selection.AutoFilter

        lr = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
        For Each rr In Range("C1:C" & lr)
        If rr Like last_received Then
        tic = 0
        End If
        Next
    Loop
于 2014-10-10T06:38:54.560 回答
0

试试这个:

   Dim c As Range, lr&
   lr = ActiveSheet.Range("C" & Rows.Count).End(xlUp).Row
   For Each c In Range("C1:C" & lr)
       If c like last_received Then 
            tic = 1
       End if
   Next
于 2013-05-23T10:35:20.363 回答