繁体   English   中英

跨工作表的VBA宏-完全合格?

[英]VBA Macro pointing across worksheets - fully qualified?

如果我的活动工作表是“管道-承保数据D”,而不是任何其他工作表,则此宏有效。

我以为是因为我不正确地限定了某些东西?

非常感谢您对代码进行调整以使其能够在不选择/激活有问题的工作表的情况下运行的任何帮助!

Dim pipe As Integer
With Sheets("Pipeline - Underwriting Data D")
    pipe = .Range("A" & .Rows.Count).End(xlUp).Row - 1
End With

With Sheets("Pipeline - Underwriting Data D")
    Dim Containword As String
    Dim rng As Range
    Set rng = Range(Cells(2, 14), Cells(pipe + 1, 14))
    Containword = "Outside Counsel"
    For Each cell In rng.Cells
        If cell.find(Containword) Is Nothing Then cell.Clear
    Next cell
End With

您缺少“。” 您的“ With”块将指向正确的范围。 见下文:

Dim pipe As Integer
With Sheets("Pipeline - Underwriting Data D")
    pipe = .Range("A" & .Rows.Count).End(xlUp).Row - 1
End With

With Sheets("Pipeline - Underwriting Data D")
    Dim Containword As String
    Dim rng As Range
    Set rng = .Range(.Cells(2, 14), .Cells(pipe + 1, 14))
    Containword = "Outside Counsel"
    For Each cell In rng.Cells
        If cell.find(Containword) Is Nothing Then cell.Clear
    Next cell
End With

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM