首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cells.find误差91

Cells.find误差91
EN

Stack Overflow用户
提问于 2014-10-07 19:14:51
回答 1查看 5.3K关注 0票数 0

我对这个代码有问题。我试图找出这段代码的问题所在,但找不到解决方案。

代码语言:javascript
复制
 Sub RDB_Worksheet_To_PDF()
        Dim FileName As String
        Dim PONumber As String
        Dim FolderPath As String

 PONumber = Sheets("Purchase Order with Sales Tax").Cells(8, 6).Value

    If ActiveWindow.SelectedSheets.Count > 1 Then
        MsgBox "There is more then one sheet selected," & vbNewLine & _
               "be aware that every selected sheet will be published"
    End If
'Call the function with the correct arguments
    FileName = RDB_Create_PDF(ActiveSheet, FolderPath & PONumber, True, True)

    If FileName <> FolderPath & PONumber Then
        'Ok, you find the PDF where you saved it
        'You can call the mail macro here if you want
        MsgBox "Sweet! The PO has been saved as a PDF." & vbNewLine & _
               "Click on the PO Number in the PO Number WorkSheet to view."
    Else
        MsgBox "Not possible to create the PDF, possible reasons:" & vbNewLine & _
               "Microsoft Add-in is not installed" & vbNewLine & _
               "There is no PO number selected" & vbNewLine & _
               "The path to Save the file in is not correct" & vbNewLine & _
               "You didn't want to overwrite the existing PDF if it exist"
    End If

    Sheets("PO Number").Select
    Range("A1").Select

我在这部分得到了错误消息91。

代码语言:javascript
复制
**Cells.Find(What:=PONumber, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False, SearchFormat:=False).Activate**

是因为我没有使用.activate,还是因为我没有使用set =?请让我知道我需要做什么。

干杯

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-10-07 19:59:56

基本上,您正在尝试找到该单元格,并同时激活它,这将提示您所提到的错误,如果没有发现。您可以先尝试找到它,然后激活:

代码语言:javascript
复制
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
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26243490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档