如何限制列的范围?(VBA)



我在District中有两列,但我需要跳过它的前两行(以限制范围(。如何做到?我的代码:

Dim VComp As Variant
ReDim vOut(1 To 14, 1 To 3)
vOut(3) = Districts.Columns(2)
vOut(2) = Mid(Districts.Columns(2), 2, 1)
vOut(1) = Len(Districts.Columns(2))

从范围中移除第一行

Districts.Resize(Districts.Rows.Count - 2).Offset(2).Columns(2)

Const fRow As Long = 3
Const Col As Long = 2
Dim Districts As Range: Set Districts = Range("A1:B10")
Dim rg2 As Range
With Districts
    Set rg2 = .Resize(.Rows.Count - fRow + 1).Offset(fRow - 1).Columns(Col)
    ' or without the constants
    'Set rg2 = .Resize(.Rows.Count - 2).Offset(2).Columns(2)
End With

最新更新