Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
4N 4N is offline
external usenet poster
 
Posts: 3
Default Copy Sheets to RAM and back

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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Copy Sheets to RAM and back

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" wrote in message
...
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.


  #3   Report Post  
Posted to microsoft.public.excel.programming
4N 4N is offline
external usenet poster
 
Posts: 3
Default Copy Sheets to RAM and back

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" ha scritto nel messaggio
...
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



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,452
Default Copy Sheets to RAM and back

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" wrote in message
...
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" ha scritto nel messaggio
...
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




  #5   Report Post  
Posted to microsoft.public.excel.programming
4N 4N is offline
external usenet poster
 
Posts: 3
Default Copy Sheets to RAM and back

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" ha scritto nel messaggio
...
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





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Copy Sheets to RAM and back

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" ha scritto nel messaggio
...
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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
copy back macro/roll back moh Excel Worksheet Functions 4 March 5th 07 02:19 PM
copy formulas from a contiguous range to a safe place and copy them back later Lucas Budlong Excel Programming 2 February 22nd 06 08:26 PM
in VBA Sheets("mysheet").Copy Befo=Sheets(1) how do i get a reference to the newly created copy of this sheet? Daniel Excel Worksheet Functions 1 July 6th 05 09:57 PM
Sheets Back Up Soniya[_2_] Excel Programming 3 January 15th 04 12:01 PM
Back Up selected sheets Soniya[_2_] Excel Programming 0 January 14th 04 12:23 PM


All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"