Selecting range of cells to copy using a variable

  • Thread starter Thread starter wfgfreedom
  • Start date Start date
W

wfgfreedom

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
 
examples

--
Don Guillett
Microsoft MVP Excel
SalesAid Software






- 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
 
lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
examples

--
Don Guillett
Microsoft MVP Excel
SalesAid Software






- 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
 
lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software





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
 
If desired, send me a workbook with your examples and snippets of these
emails.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
(e-mail address removed)
lr=cells(rows.count,"a").end(xlup).row
RANGE("A1:B"&lr).copy'NO need to select

--
Don Guillett
Microsoft MVP Excel
SalesAid Software





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
 
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
 
If desired, send me a workbook with your examples and snippets of these
emails.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software










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
 
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

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




- Show quoted text -

Thanks Tim. That helps.

Frank
 
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
(e-mail address removed)
If desired, send me a workbook with your examples and snippets of these
emails.

--
Don Guillett
Microsoft MVP Excel
SalesAid Software










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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top