Excel – 从选定行中只select列(38)中的单元格
我在电子表格中select了10k行。 现在我需要将select范围缩小到只有前面select的第38列中的单元格。
我几乎没有VBA的经验,但我用来select行的macros是
Sub selectwholerow() Selection.EntireRow.Select End Sub
所以我猜想我正在寻找什么样的方式
Sub selectcolumn() Selection.Columns(38).Select End Sub
但我真的没有线索。
Sub selectcolumn() Intersect(ActiveSheet.Columns(38), Selection.EntireRow).Select End Sub
如果您只想Select
交叉点,则可以使用:
Intersect(Selection.EntireRow, Columns(38)).Select
如果你想用指定范围做其他的事情,那么你可以使用一个函数来返回它:
Function Col38(ByRef r As Range) As Range Set Col38 = Intersect(r.EntireRow, Columns(38)) End Function
然后使用类似于:
Sub Test() Col38(Selection).Select End Sub