ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   What does this line of code do please? (https://www.excelbanter.com/excel-programming/368410-what-does-line-code-do-please.html)

[email protected]

What does this line of code do please?
 
Cells(i,"B").resize(,200).copy cells(i-1,"AS")


particularly please explain the meaning and function of (,200)
and the keywords cells, resize and copy

thankyou

Gary


DAV135

What does this line of code do please?
 
Depending on the preceeding code, i will represent a line number. For
example - 5

If i = 5 the code is basically copying the value in cell B5 and placing
it into cells AS4

Not sure what the resize is doing, can't see what changes its actually
making!


Andrew Taylor

What does this line of code do please?
 
Taking it step by step:

Cells(i,"B") gives the range that is the cell at row i, Column B

(example: if i=10, it gives the cell B10)

Cells(i,"B").Resize(,200) gives the range with the same top left
corner as Cells(i,"B") but with 200 columns. The ",200" means
that the optional first parameter to the Resize method is
omitted, and is assumed to be the number of rows in the
original range. As the original range has one row, this is
equivalent to Cells(i,"B").Resize(1,200)

(example: B10:GS10)

Cells(i,"B").resize(,200).copy copies the contents of the range
we've got so far...

and pastes it into: cells(i-1,"AS") - i.e. the range starting
at row i-1, column AS
(AS9 in the example)

So the effect is to copy the contents of B10:GS10 into AS9:IJ9

(These are all standard methods in VBA for Excel, and
are explained in detail in Help.)




wrote:
Cells(i,"B").resize(,200).copy cells(i-1,"AS")


particularly please explain the meaning and function of (,200)
and the keywords cells, resize and copy

thankyou

Gary



[email protected]

What does this line of code do please?
 
Thankyou very much,

armed with this i'm going to have another go at the problem i've been
stumped with for the last three days, when im back in the office
tomorrow.

Thanks again, I really appreciate your time

Gary.



All times are GMT +1. The time now is 12:03 PM.

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