-1

我只想offset (0,6)在我的lastRow. 有什么帮助吗?

lastRow = oSht.Range(vari1 & Rows.Count).End(xlUp).Row
4

2 回答 2

1

在您澄清之后,我可以建议您可以通过范围扩展来做到这一点。而不是Offset你可以使用Resize.

正如你所说,这对你的工作是正确的S column

oSht.Range(vari2, vari1 & lastRow).Select

在我们添加调整大小后,您将获得新的范围:

oSht.Range(vari2, vari1 & lastRow).Resize(,6).Select
于 2013-10-19T08:32:14.927 回答
0

我想这就是你想要的?

Option Explicit

Sub Sample()
    Dim oSht As Worksheet
    Dim lastRow As Long
    Dim Rng As Range
    Dim vari1 As String

    '~~> Change this to the relevant column letter
    vari1 = "S"

    '~~> Change this to the relevant sheet
    Set oSht = ThisWorkbook.Sheets("Sheet1")

    With oSht
        lastRow = .Range(vari1 & .Rows.Count).End(xlUp).Row

        Set Rng = .Range(vari1 & 2 & ":" & .Range(vari1 & lastRow).Offset(, 6).Address)

        '~~> S2:X32 in your case if lastrow is 32
        Debug.Print Rng.Address
    End With
End Sub
于 2013-10-19T07:25:51.233 回答