ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   resize question (https://www.excelbanter.com/excel-programming/342387-resize-question.html)

Gary Keramidas

resize question
 
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "R").End(xlUp).Row
Cells(lastrow, "R").Resize(1, 11).Copy
the copy statement will copy from column r over to column ab

i wanted column r to column g, so i tried
Cells(lastrow, "R").Resize(1, -11).Copy
didn't like the minus

so i used
Cells(lastrow, "R").Offset(0, -11).Resize(1, 12).Copy

why didn't the minus 11 work and is there a better way?

thanks
--

Gary




Tom Ogilvy

resize question
 
Size doesn't have anything to do with location. You can't say I want a 1
x -11 range. So you have to offset, then resize like you have shown.

or you could do

lastrow = Worksheets("Sheet1").Cells(Rows.Count, "R").End(xlUp).Row
Cells(lastrow, "H").Resize(1, 11).Copy

which would be columns H to R for the given row.
--
Regards,
Tom Ogilvy


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "R").End(xlUp).Row
Cells(lastrow, "R").Resize(1, 11).Copy
the copy statement will copy from column r over to column ab

i wanted column r to column g, so i tried
Cells(lastrow, "R").Resize(1, -11).Copy
didn't like the minus

so i used
Cells(lastrow, "R").Offset(0, -11).Resize(1, 12).Copy

why didn't the minus 11 work and is there a better way?

thanks
--

Gary






Gary Keramidas

resize question
 
thanks tom , used it

--


Gary


"Tom Ogilvy" wrote in message
...
Size doesn't have anything to do with location. You can't say I want a 1
x -11 range. So you have to offset, then resize like you have shown.

or you could do

lastrow = Worksheets("Sheet1").Cells(Rows.Count, "R").End(xlUp).Row
Cells(lastrow, "H").Resize(1, 11).Copy

which would be columns H to R for the given row.
--
Regards,
Tom Ogilvy


"Gary Keramidas" <GKeramidasATmsn.com wrote in message
...
lastrow = Worksheets("Sheet1").Cells(Rows.Count, "R").End(xlUp).Row
Cells(lastrow, "R").Resize(1, 11).Copy
the copy statement will copy from column r over to column ab

i wanted column r to column g, so i tried
Cells(lastrow, "R").Resize(1, -11).Copy
didn't like the minus

so i used
Cells(lastrow, "R").Offset(0, -11).Resize(1, 12).Copy

why didn't the minus 11 work and is there a better way?

thanks
--

Gary









All times are GMT +1. The time now is 10:08 AM.

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