ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Reading Chunks of Excel Data (https://www.excelbanter.com/excel-programming/420096-reading-chunks-excel-data.html)

Varne

Reading Chunks of Excel Data
 
Hi

Is there a VBA technique €“ direct or indirect €“ to read chunks of cells
rather than copying. The following reads b4 to both a1 and a4.

Range("a1,a4").Value = Range("b4,b1").Value

If there is none is there a technique to do copying without selecting or
activating copied or receiving area.

Can someone help?

Thanks.


joel

Reading Chunks of Excel Data
 
Why don't you want to use COPY. You DON'T need to select or activate cells
to use copy. You must be using the Macro Recorder code as your examples. I
always modify the Recorded macros to remove the activate and selection. for
example

Workbooks("book1.xls").Sheets("Sheet1").Range("A1: D4").Copy _
Destination:=Workbooks("book2.xls").Sheets("Sheet1 ").Range("A1")


or

With Workbooks("book1.xls").Sheets("Sheet1")
.Range("A1:D4").Copy _
Destination:=Workbooks("book2.xls").Sheets("Sheet1 ").Range("A1")
end With

or

Set DestSht = Workbooks("book2.xls").Sheets("Sheet1")
With Workbooks("book1.xls").Sheets("Sheet1")
.Range("A1:D4").Copy Destination:=DestSht.Range("A1")
end With


"Varne" wrote:

Hi

Is there a VBA technique €“ direct or indirect €“ to read chunks of cells
rather than copying. The following reads b4 to both a1 and a4.

Range("a1,a4").Value = Range("b4,b1").Value

If there is none is there a technique to do copying without selecting or
activating copied or receiving area.

Can someone help?

Thanks.


Varne

Reading Chunks of Excel Data
 
Hi

Thanks for the answer. I avoid copying and usually use cell by cell reading
but it takes too long if it has to read a lot.

Thanks.

"Joel" wrote:

Why don't you want to use COPY. You DON'T need to select or activate cells
to use copy. You must be using the Macro Recorder code as your examples. I
always modify the Recorded macros to remove the activate and selection. for
example

Workbooks("book1.xls").Sheets("Sheet1").Range("A1: D4").Copy _
Destination:=Workbooks("book2.xls").Sheets("Sheet1 ").Range("A1")


or

With Workbooks("book1.xls").Sheets("Sheet1")
.Range("A1:D4").Copy _
Destination:=Workbooks("book2.xls").Sheets("Sheet1 ").Range("A1")
end With

or

Set DestSht = Workbooks("book2.xls").Sheets("Sheet1")
With Workbooks("book1.xls").Sheets("Sheet1")
.Range("A1:D4").Copy Destination:=DestSht.Range("A1")
end With


"Varne" wrote:

Hi

Is there a VBA technique €“ direct or indirect €“ to read chunks of cells
rather than copying. The following reads b4 to both a1 and a4.

Range("a1,a4").Value = Range("b4,b1").Value

If there is none is there a technique to do copying without selecting or
activating copied or receiving area.

Can someone help?

Thanks.


Varne

Reading Chunks of Excel Data
 
Hi!

This is for fellow users;

Whilst trying codes shown by Joel I found something. The following confusing
codes can be used to copy data to many destinations;

Range("j1").Copy Range("j1:j500000")

"Varne" wrote:

Hi

Thanks for the answer. I avoid copying and usually use cell by cell reading
but it takes too long if it has to read a lot.

Thanks.

"Joel" wrote:

Why don't you want to use COPY. You DON'T need to select or activate cells
to use copy. You must be using the Macro Recorder code as your examples. I
always modify the Recorded macros to remove the activate and selection. for
example

Workbooks("book1.xls").Sheets("Sheet1").Range("A1: D4").Copy _
Destination:=Workbooks("book2.xls").Sheets("Sheet1 ").Range("A1")


or

With Workbooks("book1.xls").Sheets("Sheet1")
.Range("A1:D4").Copy _
Destination:=Workbooks("book2.xls").Sheets("Sheet1 ").Range("A1")
end With

or

Set DestSht = Workbooks("book2.xls").Sheets("Sheet1")
With Workbooks("book1.xls").Sheets("Sheet1")
.Range("A1:D4").Copy Destination:=DestSht.Range("A1")
end With


"Varne" wrote:

Hi

Is there a VBA technique €“ direct or indirect €“ to read chunks of cells
rather than copying. The following reads b4 to both a1 and a4.

Range("a1,a4").Value = Range("b4,b1").Value

If there is none is there a technique to do copying without selecting or
activating copied or receiving area.

Can someone help?

Thanks.



All times are GMT +1. The time now is 05:44 PM.

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