PC Review


Reply
Thread Tools Rate Thread

Copy Sheets to RAM and back

 
 
4N
Guest
Posts: n/a
 
      18th Nov 2007
Hi,

I right now copy a sheet inside a "Variant" matrix using a command like

sheet.Cells(y,x) = matrix(y,x)
and back
matrix(y,x) = sheet.Cells(y,x)

Is there a way to copy the entire table at once or a command to stop
updating the sheet untill I'm done copying to speedup the process?

Thanks.


 
Reply With Quote
 
 
 
 
RB Smissaert
Guest
Posts: n/a
 
      18th Nov 2007
I take it that your are running your code in a nested loop. You can avoid
that by
assigning the range to the array (and opposite) in one go by doing:

Range(Cells(1), Cells(100, 100)) = Matrix

Matrix = Range(Cells(1), Cells(100, 100))


RBS


"4N" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I right now copy a sheet inside a "Variant" matrix using a command like
>
> sheet.Cells(y,x) = matrix(y,x)
> and back
> matrix(y,x) = sheet.Cells(y,x)
>
> Is there a way to copy the entire table at once or a command to stop
> updating the sheet untill I'm done copying to speedup the process?
>
> Thanks.
>


 
Reply With Quote
 
4N
Guest
Posts: n/a
 
      20th Nov 2007
It actually works, but not with every sheet, the Range function in fact
fails in some case.
I tryed activating the other sheets prior to copying them and it looks like
it works.
This method has also a limitation: it doesn't allow copy of portions of the
tables because the table in ram obviously doesn't have the function Range.
Any workaround?

Thanks again.

"RB Smissaert" <(E-Mail Removed)> ha scritto nel messaggio
news:(E-Mail Removed)...
>I take it that your are running your code in a nested loop. You can avoid
>that by
> assigning the range to the array (and opposite) in one go by doing:
>
> Range(Cells(1), Cells(100, 100)) = Matrix
>
> Matrix = Range(Cells(1), Cells(100, 100))
>
>
> RBS



 
Reply With Quote
 
RB Smissaert
Guest
Posts: n/a
 
      20th Nov 2007
You don't have to activate the sheets. You can do:

With Sheets(x)
.Range(.Cells(1), .Cells(100, 100)) = Matrix

Matrix = .Range(.Cells(1), .Cells(100, 100))
End With

I don't think you can get a part of an array without
running a loop.


RBS

"4N" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> It actually works, but not with every sheet, the Range function in fact
> fails in some case.
> I tryed activating the other sheets prior to copying them and it looks
> like it works.
> This method has also a limitation: it doesn't allow copy of portions of
> the tables because the table in ram obviously doesn't have the function
> Range.
> Any workaround?
>
> Thanks again.
>
> "RB Smissaert" <(E-Mail Removed)> ha scritto nel messaggio
> news:(E-Mail Removed)...
>>I take it that your are running your code in a nested loop. You can avoid
>>that by
>> assigning the range to the array (and opposite) in one go by doing:
>>
>> Range(Cells(1), Cells(100, 100)) = Matrix
>>
>> Matrix = Range(Cells(1), Cells(100, 100))
>>
>>
>> RBS

>
>


 
Reply With Quote
 
4N
Guest
Posts: n/a
 
      21st Nov 2007
I used
With Sheets(2)
.Range(.Cells(1), .Cells(100, 100)) = Matrix
End With

and I ended up having the earlier mentioned error.
I guess the above commands are equivalent to
sheet2.Range(.Cells(1), .Cells(100, 100)) = Matrix

and that doesn't work without activating the sheet.
That isn't a big deal anyway...

"RB Smissaert" <(E-Mail Removed)> ha scritto nel messaggio
news:%(E-Mail Removed)...
> You don't have to activate the sheets. You can do:
>
> With Sheets(x)
> .Range(.Cells(1), .Cells(100, 100)) = Matrix
>
> Matrix = .Range(.Cells(1), .Cells(100, 100))
> End With
>
> I don't think you can get a part of an array without
> running a loop.
>
>
> RBS



 
Reply With Quote
 
Dave Peterson
Guest
Posts: n/a
 
      21st Nov 2007
Nope. It's equivalent to:

sheet2.Range(sheet2.Cells(1), sheet2.Cells(100, 100)) = Matrix
or
sheets(2).Range(sheets(2).Cells(1), sheets(2).Cells(100, 100)) = Matrix

Each range reference (.range() and .cells()) has to be qualified.


4N wrote:
>
> I used
> With Sheets(2)
> .Range(.Cells(1), .Cells(100, 100)) = Matrix
> End With
>
> and I ended up having the earlier mentioned error.
> I guess the above commands are equivalent to
> sheet2.Range(.Cells(1), .Cells(100, 100)) = Matrix
>
> and that doesn't work without activating the sheet.
> That isn't a big deal anyway...
>
> "RB Smissaert" <(E-Mail Removed)> ha scritto nel messaggio
> news:%(E-Mail Removed)...
> > You don't have to activate the sheets. You can do:
> >
> > With Sheets(x)
> > .Range(.Cells(1), .Cells(100, 100)) = Matrix
> >
> > Matrix = .Range(.Cells(1), .Cells(100, 100))
> > End With
> >
> > I don't think you can get a part of an array without
> > running a loop.
> >
> >
> > RBS


--

Dave Peterson
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets) septhemis@gmail.com Microsoft Excel Programming 3 30th Jan 2009 04:20 PM
Re: Copy Two Visible Ranges (From Two Sheets) To A New Workbook (AlsoWith Two Sheets) septhemis@gmail.com Microsoft Excel Programming 0 29th Jan 2009 01:35 PM
copy WB without VBA: copied sheets link back to source WB Dan Williams Microsoft Excel Programming 2 28th Dec 2007 05:22 PM
in VBA Sheets("mysheet").Copy Before:=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Microsoft Excel Discussion 1 6th Jul 2005 10:05 PM
in VBA Sheets("mysheet").Copy Before:=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Microsoft Excel Worksheet Functions 1 6th Jul 2005 09:57 PM


Features
 

Advertising
 

Newsgroups
 


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