Cells.find error 91

前端 未结 1 550
無奈伤痛
無奈伤痛 2020-12-12 06:37

I have problems with this code. I tried to figure it what is wrong with this code, but cannot find the solution

 Sub RDB_Worksheet_To_PDF()
        Dim FileN         


        
1条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 07:07

    Basically you are trying to find the cell AND activate it at the same time, which will prompt you the error mentioned if nothing is found. You could try find it first then activate:

    set smvar = Cells.Find(What:=PONumber, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False)  
    if not smvar is Nothing then smvar.activate
    

    0 讨论(0)
提交回复
热议问题