'Using variable range
I have this range
Range("G8:G" & Range("F" & Rows.Count).End(xlUp).Offset(-1, 0).Row)
, and I would like to replace the values with variables because the range will change. I was thinking of using Cells like Range(Cells(8, trow) etc, but I can't get it to work. Does anyone know how I would replace the range items with variables? I want to do this because the column will change depending on how much data I have, but it will always start at 8.
Solution 1:[1]
Something along these lines:
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))
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tim Williams |
