使用变量范围

Using variable range

我有这个范围

Range("G8:G" & Range("F" & Rows.Count).End(xlUp).Offset(-1, 0).Row)

,我想用变量替换值,因为范围会改变。我正在考虑使用 Cells 之类的 Range(Cells(8, trow) 等,但我无法让它工作。有谁知道我将如何用变量替换范围项?我想这样做是因为列会根据我有多少数据而改变,但它总是从 8 开始。

大致如下:

Dim ws As Worksheet, rng as range, col

Set ws = ActiveSheet 'or whatever

col = 3 'or "C", for example

Set rng = ws.Range(ws.Cells(8, col), _
                   ws.Cells(ws.Rows.Count, col).End(xlUp).Offset(-1))