将 table 行设置为范围
Setting a table row as a range
一旦我通过 for 循环确定了一个感兴趣的单元格,我如何才能从包含所述感兴趣单元格的整个 table 行中创建一个范围?
我只需要较大代码的一小部分帮助。
'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 的整个 table 行。
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
根据我对您上一个问题的回答:
Trans_new_NPD_row.Range.Value = _
Application.Intersect(TransCell.EntireRow, QueueTable.DataBodyRange).Value
您可以使用 Intersect 找到 TransCell.EntireRow
的公共范围和 table/listobject 的数据部分。
一旦我通过 for 循环确定了一个感兴趣的单元格,我如何才能从包含所述感兴趣单元格的整个 table 行中创建一个范围? 我只需要较大代码的一小部分帮助。
'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 的整个 table 行。
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
根据我对您上一个问题的回答:
Trans_new_NPD_row.Range.Value = _
Application.Intersect(TransCell.EntireRow, QueueTable.DataBodyRange).Value
您可以使用 Intersect 找到 TransCell.EntireRow
的公共范围和 table/listobject 的数据部分。