简体   繁体   English

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

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

This macro works if my active worksheet is "Pipeline - Underwriting Data D" but not from any other worksheet. 如果我的活动工作表是“管道-承保数据D”,而不是任何其他工作表,则此宏有效。

I'm assuming it's because I'm incorrectly qualifying something? 我以为是因为我不正确地限定了某些东西?

Any help in tweaking the code so that it will run without selecting/activating the worksheet in question would be very much appreciated! 非常感谢您对代码进行调整以使其能够在不选择/激活有问题的工作表的情况下运行的任何帮助!

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

You are missing the "." 您缺少“。” for your "With" block that would point to the right range. 您的“ With”块将指向正确的范围。 See below: 见下文:

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