ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Resize offset (https://www.excelbanter.com/excel-programming/386818-resize-offset.html)

ward376

Resize offset
 
I'm using a statement like the following to fill some columns (minus
the header, row 1) with formulas or functions.

With ThisWorkbook.Sheets("sheet1").Cells(1, 1).CurrentRegion.Offset(1,
0)
.Columns(25).FormulaR1C1 = "=someformula"
end with

How can I use resize to avoid creating an additional used row at the
bottom? I've been fooling with it for a bit now, and I clearly am not
understanding it completely. The code works fine as is, but then I
have to go get rid of the extra row(s) afterwards.

Thanks!
Ward376


Dave Peterson

Resize offset
 
I'd use something like:

Dim myRng as range
with ThisWorkbook.Sheets("sheet1").Cells(1, 1).CurrentRegion
set myrng = .resize(.rows.count-1,1).offset(0,24) 'same as 25th column
end with
myrng.formular1c1 = "=someformulainr1c1reference style"



ward376 wrote:

I'm using a statement like the following to fill some columns (minus
the header, row 1) with formulas or functions.

With ThisWorkbook.Sheets("sheet1").Cells(1, 1).CurrentRegion.Offset(1,
0)
.Columns(25).FormulaR1C1 = "=someformula"
end with

How can I use resize to avoid creating an additional used row at the
bottom? I've been fooling with it for a bit now, and I clearly am not
understanding it completely. The code works fine as is, but then I
have to go get rid of the extra row(s) afterwards.

Thanks!
Ward376


--

Dave Peterson

ward376

Resize offset
 
How about if I want to use the first column?


ward376

Resize offset
 
Can I set this range in one line?



ward376

Resize offset
 
I keep getting an object/application-defined error at the Set line.


Tom Ogilvy

Resize offset
 
Show the code

"ward376" wrote:

I keep getting an object/application-defined error at the Set line.




All times are GMT +1. The time now is 01:35 AM.

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