我的工作表有多个表/列表对象。我试图一次选择一个表(以连续的视图顺序而不是表号,因为在某些点上可能存在已经存在的表之间插入的表)。选择表,转换为范围,然后声明/设置该范围以供将来使用。我无法弄清楚如何这样做,因为范围必须用常量而不是变量声明。这是我到目前为止的代码:
Dim LastRow As Long, c As Range
LastRow = Cells(Cells.Rows.Count, "A").End(xlUp).row
Dim n As Integer
n = 1
Dim tableName As String
Dim SelectedCell As Range
For Each c In Range("B6:B" & LastRow)
If c.Text = "Column1" Then
c.Activate
Set SelectedCell = ActiveCell
tableName = SelectedCell.ListObject.Name
ActiveSheet.ListObjects(tableName).Range.Select
ActiveSheet.ListObjects(tableName).Unlist
Dim rng(n) As Range
Set rng(n) = Selection
n = n + 1
End If
Next
答案 0 :(得分:0)
df[df[0].str.contains('(Hel|Just)', regex=True)]
(以及ReDim
不删除存储的参数)。同样,它需要Preserve
,这应该没有问题:
Variant