excel - 将表格行设置为范围
问题描述
一旦我通过 for 循环识别了一个感兴趣的单元格,我如何才能从包含所述感兴趣的单元格的整个表格行中创建一个范围?我只需要我较大代码的一小部分的帮助。
'TransColumn is a table column in which I am looking for the phrase "NPD".
'TransCell is my cell of interest, containing the phrase "NPD".
'I want Trans_Queue_Row to be the table row in which TransCell is located.
For Each TransCell In TransColumn
If InStr(1, TransCell.Value, "NPD") > 0 Then
Dim Trans_Queue_Row As Range
Set Trans_Queue_Row = ThisWorkbook.Sheets("Project Queue").ListObjects("TableQueue").ListRows
'I know this looks like a weird way to achieve what I'm asking for, but I'm using InStr to support some other elements of my code not displayed here.
我想要一个变量(即 - Trans_Queue_Row)来标识包含 TransCell 的整个表行。
解决方案
Dim TableQueue as ListObject, Trans_Queue_Row As Range, i as Long
Set TableQueue = ThisWorkbook.Sheets("Project Queue").ListObjects("TableQueue")
With TransColumn.DataBodyRange
For i = 1 To .Count
If InStr(1, .Rows(i).Value, "NPD") > 0 Then
Set Trans_Queue_Row = TableQueue.DataBodyRange.Rows(i)
End If
Next i
End With
推荐阅读
- python - Reshaping of a tensor with adaptive shape results in unexpected resulting shape
- powershell - 导出不是某些组成员的组的 csv
- php - 统计登录的用户数量
- r - 使用向量的元素与命名列表相交
- c# - 如何从 Azure AD 获取帐户?
- perl - 通过引用和标量变量传递 Perl 哈希
- angular - 如何在 Angular 5+ 中隐藏地址栏中的路线?
- python - 从 CountVectorizer Vector 创建的 DataFrame 的命名列
- c# - 处理线程静态变量
- postgresql - 取消 knex.js 中的流式 postgres 查询