简体   繁体   English

EXCEL VBA 到 select ROWS 如果单元格 A5 包含特定文本 - 警告

[英]EXCEL VBA to select ROWS if Cell A5 contains specific text - caveats

I receive an excel file daily.我每天都会收到一份 excel 文件。 I am trying to select all ROWS if cells from A5 to the end of the dynamic data contains a string "TURNER 232"如果从 A5 到动态数据末尾的单元格包含字符串“TURNER 232”,我正在尝试 select 所有 ROWS

  • Cells A1 to A3 are blank单元格 A1 到 A3 为空白
  • Cells A4 are the column headings单元格 A4 是列标题
  • Cells A5 to the dynamic end of the sheet always contain "TURNER 232"表格动态末尾的单元格 A5 始终包含“TURNER 232”

I have been copying various examples of code from this website to no avail.我一直在从该网站复制各种代码示例,但无济于事。

Would appreciate any assistance if possible.如果可能的话,将不胜感激。

例子

Many thanks Matt非常感谢马特

Code used使用的代码

Sub CustomSelect()
    Dim i As Long: i = 2
    Do While Range("H" & i).Value = "TURNER 232"
        i = i + 1
    Loop
    Range("A5:H" & i - 1).EntireRow.Select
End Sub

Scott,斯科特,

I used the below which did the trick.我使用了下面的方法。

Thanks mate.1st ever soiree into VBA感谢伙伴。第一次参加 VBA 的晚会

Sub CustomSelect()
     Dim i As Long: i = 5
     Do While Range("A" & i).Value = "TURNER 232"
        i = i + 1
     Loop
     Range("A5:A" & i - 1).EntireRow.Select
End Sub

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

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