ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Re-define a range in cells (https://www.excelbanter.com/excel-programming/330586-re-define-range-cells.html)

Geoff

Re-define a range in cells
 
Hi
How do i re-define the following range in cell notation so variables can be
used for the column and row?

Dim tbl as range
Set tbl = .Range(.Range("D6"), .Range("D6:D" &
..Range("D65536").End(xlUp).Row))
Works fine but is fixed.

Dim rownum as integer
Dim colnum as integer
rownum=6 'initially
colnum=4 'initially

I just cannot get anything to work. The next line seemed ok at first and
produced the expected answer. But then it failed and in testing i found it
produced "D5:Dxxxx and not D6:Dxxxx as expected.

Set tbl = .Range(.Cells(6, colnum), .Cells(65536, colnum).End(xlUp))

I would very much appreciate some help on something which seems so simple to
convert.

T.I.A.

Geoff



All times are GMT +1. The time now is 05:01 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com