ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Using variables to define a range of cells? (https://www.excelbanter.com/excel-programming/368188-using-variables-define-range-cells.html)

Matt[_39_]

Using variables to define a range of cells?
 
Is there a way to refer to a range of cells completely by variables:
Range((A,B), (C,D))
where A, B, C and D are integer variables

any help would be appreciated
thanks


Chip Pearson

Using variables to define a range of cells?
 
Matt,

The following code will select B1:D3

Dim A As Integer: A = 1
Dim B As Integer: B = 2
Dim C As Integer: C = 3
Dim D As Integer: D = 4

Range(Cells(A, B), Cells(C, D)).Select


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Matt" wrote in message
oups.com...
Is there a way to refer to a range of cells completely by
variables:
Range((A,B), (C,D))
where A, B, C and D are integer variables

any help would be appreciated
thanks




Matt[_39_]

Using variables to define a range of cells?
 
Thanks, exactly what I was looking for (should have guessed it would be
as simple as putting Cells in, must be a long day for me already)



All times are GMT +1. The time now is 06:29 AM.

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