I have a 10k rows selected in my spreadsheet. Now I need to narrow down that selection to only the cells in column 38 from the previous selection.
I have almost zero experience with VBA but the macro I used to select the rows was
Sub selectwholerow()
Selection.EntireRow.Select
End Sub
So I guess what I'm looking for sort of along the lines of
Sub selectcolumn()
Selection.Columns(38).Select
End Sub
But I have no clue really.
Sub selectcolumn()
Intersect(ActiveSheet.Columns(38), Selection.EntireRow).Select
End Sub
If you just want to Select
the intersection, you could use:
Intersect(Selection.EntireRow, Columns(38)).Select
If you want to do something else with that specified range, then you could use a function to return it:
Function Col38(ByRef r As Range) As Range
Set Col38 = Intersect(r.EntireRow, Columns(38))
End Function
Then use something like:
Sub Test()
Col38(Selection).Select
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.