Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default memory issues

I have a macro that opens sequentially 34 quite large spreadsheets and copies
data from up to 10 cells in each and pastes it to one spreadsheet. I am
using the
sourcedata.copy to destinationrange
this is causing terrible memory problems.
Does anyone have any ideas how i get around this. The destination
spreadsheet also has about 400 linked cells to 3 other workbooks.

I also have another issue in that the spreadsheets that are being opened to
copy data from have a macro that is fired on closing the spreadsheet that
produces a message box asking if the user wishes to update. The code on this
spreadsheet is protected how do i avoid having to cancel each message box to
enable the spreadsheet to close.

Any help will be much appreciated

Regards

Spike
--
with kind regards

Spike
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 747
Default memory issues

You don't need to open a workbook to get data from it. Ron Debruin has code
that allows you to obtain data without opening the wb:

http://www.rondebruin.nl/ado.htm

The following is another example of how to get data from closed wbs. Assumed
is that the data from all source wbs is in column A starting at A1. Also
assumed is that you want to copy to the destination wb into column A starting
in cell A1 for the first source wb and then to column B for the second source
wb and so forth. Minimal testing:

Sub TransferData()
Dim c As Range, cc As Range
Dim ws As Worksheet
Dim P As String, FN As String
Dim FileNameArr As Variant
Dim i As Long, ii As Long, Pos As Long

On Error GoTo ExitProc
FileNameArr = Application.GetOpenFilename _
("Excel Files(*.xls), *.xls", MultiSelect:=True)
If VarType(FileNameArr) = vbBoolean Then Exit Sub
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
Set ws = ThisWorkbook.Sheets("Sheet1") 'Destination ws
Set c = ws.Range("A1") 'Top cell in destination range
Pos = InStrRev(FileNameArr(1), "\")
P = Left(FileNameArr(1), Pos - 1) 'Path of first source wb
For i = LBound(FileNameArr) To UBound(FileNameArr)
FN = Dir(FileNameArr(i)) 'Iterate through source wb names
ii = 1
Do
Set cc = c(ii, i)
cc.Formula = "='" & P & "\[" & FN & "]Sheet1'!" & c(ii,
1).Address & ""
cc.Value = cc.Value 'Transform formulas to values
ii = ii + 1
Loop Until cc.Value = 0
cc.ClearContents
Next i
ExitProc:
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub

Regards,
Greg

"Spike" wrote:

I have a macro that opens sequentially 34 quite large spreadsheets and copies
data from up to 10 cells in each and pastes it to one spreadsheet. I am
using the
sourcedata.copy to destinationrange
this is causing terrible memory problems.
Does anyone have any ideas how i get around this. The destination
spreadsheet also has about 400 linked cells to 3 other workbooks.

I also have another issue in that the spreadsheets that are being opened to
copy data from have a macro that is fired on closing the spreadsheet that
produces a message box asking if the user wishes to update. The code on this
spreadsheet is protected how do i avoid having to cancel each message box to
enable the spreadsheet to close.

Any help will be much appreciated

Regards

Spike
--
with kind regards

Spike

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default memory issues

For the OP

Ado is a good option, another option is to create links to the workbooks
http://www.rondebruin.nl/summary2.htm



--
Regards Ron de Bruin
http://www.rondebruin.nl


"Greg Wilson" wrote in message ...
You don't need to open a workbook to get data from it. Ron Debruin has code
that allows you to obtain data without opening the wb:

http://www.rondebruin.nl/ado.htm

The following is another example of how to get data from closed wbs. Assumed
is that the data from all source wbs is in column A starting at A1. Also
assumed is that you want to copy to the destination wb into column A starting
in cell A1 for the first source wb and then to column B for the second source
wb and so forth. Minimal testing:

Sub TransferData()
Dim c As Range, cc As Range
Dim ws As Worksheet
Dim P As String, FN As String
Dim FileNameArr As Variant
Dim i As Long, ii As Long, Pos As Long

On Error GoTo ExitProc
FileNameArr = Application.GetOpenFilename _
("Excel Files(*.xls), *.xls", MultiSelect:=True)
If VarType(FileNameArr) = vbBoolean Then Exit Sub
With Application
.ScreenUpdating = False
.Calculation = xlCalculationManual
Set ws = ThisWorkbook.Sheets("Sheet1") 'Destination ws
Set c = ws.Range("A1") 'Top cell in destination range
Pos = InStrRev(FileNameArr(1), "\")
P = Left(FileNameArr(1), Pos - 1) 'Path of first source wb
For i = LBound(FileNameArr) To UBound(FileNameArr)
FN = Dir(FileNameArr(i)) 'Iterate through source wb names
ii = 1
Do
Set cc = c(ii, i)
cc.Formula = "='" & P & "\[" & FN & "]Sheet1'!" & c(ii,
1).Address & ""
cc.Value = cc.Value 'Transform formulas to values
ii = ii + 1
Loop Until cc.Value = 0
cc.ClearContents
Next i
ExitProc:
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
End With
End Sub

Regards,
Greg

"Spike" wrote:

I have a macro that opens sequentially 34 quite large spreadsheets and copies
data from up to 10 cells in each and pastes it to one spreadsheet. I am
using the
sourcedata.copy to destinationrange
this is causing terrible memory problems.
Does anyone have any ideas how i get around this. The destination
spreadsheet also has about 400 linked cells to 3 other workbooks.

I also have another issue in that the spreadsheets that are being opened to
copy data from have a macro that is fired on closing the spreadsheet that
produces a message box asking if the user wishes to update. The code on this
spreadsheet is protected how do i avoid having to cancel each message box to
enable the spreadsheet to close.

Any help will be much appreciated

Regards

Spike
--
with kind regards

Spike



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 139
Default memory issues

Spike:

you can disable even and change Calculation property

try,

Dim wbk As Workbook
Application.EnableEvents = False
Application.Calculation = xlCalculationManual
Set wbk = Workbooks.Open("C:\123.xls")
ThisWorkbook.Sheets("Sheet1").Range("A1:A10").Copy _
wbk.Sheets("Sheet1").Range("A1:A10")
wbk.Close SaveChanges:=True
Application.Calculation = xlCalculationAutomatic
Application.EnableEvents = True

--
天行健,君*以自強不息
地勢坤,君*以厚德載物

http://www.vba.com.tw/plog/


"Spike" wrote:

I have a macro that opens sequentially 34 quite large spreadsheets and copies
data from up to 10 cells in each and pastes it to one spreadsheet. I am
using the
sourcedata.copy to destinationrange
this is causing terrible memory problems.
Does anyone have any ideas how i get around this. The destination
spreadsheet also has about 400 linked cells to 3 other workbooks.

I also have another issue in that the spreadsheets that are being opened to
copy data from have a macro that is fired on closing the spreadsheet that
produces a message box asking if the user wishes to update. The code on this
spreadsheet is protected how do i avoid having to cancel each message box to
enable the spreadsheet to close.

Any help will be much appreciated

Regards

Spike
--
with kind regards

Spike

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
Pivot tables - memory issues - please help apss40 Excel Discussion (Misc queries) 2 June 20th 09 01:38 AM
XL 2007 - Out of Memory - memory leak/bug? PCLIVE Excel Discussion (Misc queries) 0 March 23rd 09 03:31 PM
Excel Memory Issues TXSteveO Excel Discussion (Misc queries) 4 January 1st 07 01:26 AM
memory issues with Excel raj Excel Programming 1 September 19th 03 01:32 PM
Memory Issues keepitcool Excel Programming 0 August 25th 03 02:47 AM


All times are GMT +1. The time now is 01:25 AM.

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

About Us

"It's about Microsoft Excel"