ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting range of cells to copy using a variable (https://www.excelbanter.com/excel-programming/404983-selecting-range-cells-copy-using-variable.html)

[email protected]

Selecting range of cells to copy using a variable
 
I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.

Frank

Don Guillett

Selecting range of cells to copy using a variable
 
examples


--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
...
I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.

Frank



[email protected]

Selecting range of cells to copy using a variable
 
On Jan 24, 8:08*pm, "Don Guillett" wrote:
examples

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message

...



I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.


Frank- Hide quoted text -


- Show quoted text -


I'm still lost. I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.

Eg. RANGE(Start:End).Select

Can anyone help.

Frank

Don Guillett

Selecting range of cells to copy using a variable
 
lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
...
On Jan 24, 8:08 pm, "Don Guillett" wrote:
examples

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message

...



I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.


Frank- Hide quoted text -


- Show quoted text -


I'm still lost. I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.

Eg. RANGE(Start:End).Select

Can anyone help.

Frank


[email protected]

Selecting range of cells to copy using a variable
 
On Jan 25, 8:08*am, "Don Guillett" wrote:
lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message

...
On Jan 24, 8:08 pm, "Don Guillett" wrote:





examples


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message


...


I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.


Frank- Hide quoted text -


- Show quoted text -


I'm still lost. *I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.

Eg. RANGE(Start:End).Select

Can anyone help.

Frank- Hide quoted text -

- Show quoted text -


I don't know the start cell, because it can change as well. I need to
control both the start and end cell using a variable. Can you show
how this is possible?

Frank

Don Guillett

Selecting range of cells to copy using a variable
 
If desired, send me a workbook with your examples and snippets of these
emails.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
...
On Jan 25, 8:08 am, "Don Guillett" wrote:
lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message

...
On Jan 24, 8:08 pm, "Don Guillett" wrote:





examples


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message


...


I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.


Frank- Hide quoted text -


- Show quoted text -


I'm still lost. I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.

Eg. RANGE(Start:End).Select

Can anyone help.

Frank- Hide quoted text -

- Show quoted text -


I don't know the start cell, because it can change as well. I need to
control both the start and end cell using a variable. Can you show
how this is possible?

Frank


Tim Zych

Selecting range of cells to copy using a variable
 
If Start is A1 and End is C2, here are different ways to do it.

Range(Range("A1"), Range("C2")).Select

Range(Cells(1, "A"), Cells(2, "C")).Select

Range(Cells(1, 1), Cells(2, 3)).Select

Range("A1").Resize(2, 3).Select

Range(Range("Start"),Range("End")).Select

--
Tim Zych
SF, CA

------------------
I'm still lost. I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.


Eg. RANGE(Start:End).Select


Can anyone help.


Frank




[email protected]

Selecting range of cells to copy using a variable
 
On Jan 25, 6:31*pm, "Don Guillett" wrote:
If desired, send me a workbook with your examples and snippets of these
emails.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message

...
On Jan 25, 8:08 am, "Don Guillett" wrote:





lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message


...
On Jan 24, 8:08 pm, "Don Guillett" wrote:


examples


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message


....


I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How can
I select a range with this variable to copy and paste the range of
cells.


Frank- Hide quoted text -


- Show quoted text -


I'm still lost. I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.


Eg. RANGE(Start:End).Select


Can anyone help.


Frank- Hide quoted text -


- Show quoted text -


I don't know the start cell, because it can change as well. I need to
control both the start and end cell using a variable. *Can you show
how this is possible?

Frank- Hide quoted text -

- Show quoted text -


TableSize = TableSize + 1
Do While Cells(TableSize, 1) < ""
TableSize = TableSize + 1
Loop

Range("A1:K" &TableSize).Select
Selection.Copy
Cells(TableSize*2+5,1).select
ActiveSheet.Paste

Range("C &TableSize*2+5:C" &TableSize*2+6).Select
Application.CutCopyMode = False
Selection.Merge

Above is an example. I start with a loop to determine the size of the
table. Then I make a copy of this table. Next, I need to select two
cells to merge them together. I don't know the absolute value of
these cells. How can I accomplish this?

Frank


[email protected]

Selecting range of cells to copy using a variable
 
On Jan 25, 6:48*pm, "Tim Zych" <tzych@NOSp@mE@RTHLINKDOTNET wrote:
If Start is A1 and End is C2, here are different ways to do it.

Range(Range("A1"), Range("C2")).Select

Range(Cells(1, "A"), Cells(2, "C")).Select

Range(Cells(1, 1), Cells(2, 3)).Select

Range("A1").Resize(2, 3).Select

Range(Range("Start"),Range("End")).Select

--
Tim Zych
SF, CA

------------------



I'm still lost. *I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.
Eg. RANGE(Start:End).Select
Can anyone help.
Frank- Hide quoted text -


- Show quoted text -


Thanks Tim. That helps.

Frank

Don Guillett

Selecting range of cells to copy using a variable
 
I still can't determine what you want. As I said, send a wb with a clear
explanation and before/after examples.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

wrote in message
...
On Jan 25, 6:31 pm, "Don Guillett" wrote:
If desired, send me a workbook with your examples and snippets of these
emails.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message

...
On Jan 25, 8:08 am, "Don Guillett" wrote:





lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message


...
On Jan 24, 8:08 pm, "Don Guillett" wrote:


examples


--
Don Guillett
Microsoft MVP Excel
SalesAid Software
wrote in message


...


I need to copy a range of cells but the size of the range may change.
I will be using a variable to determine the size of the table. How
can
I select a range with this variable to copy and paste the range of
cells.


Frank- Hide quoted text -


- Show quoted text -


I'm still lost. I'm trying to get something like RANGE(A1:B4).Select,
but I don't have a predefined range and need to use variables.


Eg. RANGE(Start:End).Select


Can anyone help.


Frank- Hide quoted text -


- Show quoted text -


I don't know the start cell, because it can change as well. I need to
control both the start and end cell using a variable. Can you show
how this is possible?

Frank- Hide quoted text -

- Show quoted text -


TableSize = TableSize + 1
Do While Cells(TableSize, 1) < ""
TableSize = TableSize + 1
Loop

Range("A1:K" &TableSize).Select
Selection.Copy
Cells(TableSize*2+5,1).select
ActiveSheet.Paste

Range("C &TableSize*2+5:C" &TableSize*2+6).Select
Application.CutCopyMode = False
Selection.Merge

Above is an example. I start with a loop to determine the size of the
table. Then I make a copy of this table. Next, I need to select two
cells to merge them together. I don't know the absolute value of
these cells. How can I accomplish this?

Frank



All times are GMT +1. The time now is 09:47 PM.

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