ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   offset property to define range (https://www.excelbanter.com/excel-programming/280514-offset-property-define-range.html)

Art[_5_]

offset property to define range
 
I have an object variable for a range on the spreadsheet.
What is the easiest way to select a rectangular range on
the spreadsheet using the offset property (or something
similar).

I have this so far:

Dim testRng As Range
Set testRng = Worksheets("Sheet1").Range("A1:D20")
testRng.Value = 9
testRng.Cells(4 to 6,1 to 3).ClearContents 'error "to"

Dick Kusleika[_3_]

offset property to define range
 
Art

testRng.Cells(1).Offset(3,0).Resize(3,3).ClearCont ents

--
Dick Kusleika
MVP - Excel
www.dicks-clicks.com
Post all replies to the newsgroup.

"Art" wrote in message
...
I have an object variable for a range on the spreadsheet.
What is the easiest way to select a rectangular range on
the spreadsheet using the offset property (or something
similar).

I have this so far:

Dim testRng As Range
Set testRng = Worksheets("Sheet1").Range("A1:D20")
testRng.Value = 9
testRng.Cells(4 to 6,1 to 3).ClearContents 'error "to"




Alan Beban[_4_]

offset property to define range
 
testRng(4, 1).Resize(3, 3).ClearContents is probably easier.

Alan Beban

Dick Kusleika wrote:
Art

testRng.Cells(1).Offset(3,0).Resize(3,3).ClearCont ents




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

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