ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   copy a range with known start column to variable end column (https://www.excelbanter.com/excel-programming/369128-copy-range-known-start-column-variable-end-column.html)

Matilda

copy a range with known start column to variable end column
 
Dear All,

Within a loop, I want to copy a range of values then paste to another range.
I don't know the syntax to write a variable into the range address.

activesheet.range("myVariableCol myVarRow", "myVarCol myVarRow").copy_
otherSheet.range("myVarCol myVarRow")
is what I am trying to achieve.
- The two positions are in the same absolute address in both sheets.

Any help appreciated,

Matilda

Ron de Bruin

copy a range with known start column to variable end column
 
Use it like this
For testing it select the range

myVarRow1 = 2
myVariableCol1 = 1
myVarRow2 = 10
myVariableCol2 = 3

Range(Cells(myVarRow1, myVariableCol1), Cells(myVarRow2, myVariableCol2)).Select


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Matilda" wrote in message ...
Dear All,

Within a loop, I want to copy a range of values then paste to another range.
I don't know the syntax to write a variable into the range address.

activesheet.range("myVariableCol myVarRow", "myVarCol myVarRow").copy_
otherSheet.range("myVarCol myVarRow")
is what I am trying to achieve.
- The two positions are in the same absolute address in both sheets.

Any help appreciated,

Matilda




Matilda

copy a range with known start column to variable end column
 
I get it! Many thanks Ron

"Ron de Bruin" wrote:

Use it like this
For testing it select the range

myVarRow1 = 2
myVariableCol1 = 1
myVarRow2 = 10
myVariableCol2 = 3

Range(Cells(myVarRow1, myVariableCol1), Cells(myVarRow2, myVariableCol2)).Select


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Matilda" wrote in message ...
Dear All,

Within a loop, I want to copy a range of values then paste to another range.
I don't know the syntax to write a variable into the range address.

activesheet.range("myVariableCol myVarRow", "myVarCol myVarRow").copy_
otherSheet.range("myVarCol myVarRow")
is what I am trying to achieve.
- The two positions are in the same absolute address in both sheets.

Any help appreciated,

Matilda






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

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