S
stochastic
I have a large worksheet: 120 columns and 30000 rows
filled up with numeric values (plain values; no formulas,
no formatting of any kind). All I want to do is
programmatically copy this data onto another worksheet
in the same workbook.
It's puzzling and frustrating to see that several
alternative approaches have failed! In all cases, the
result is "Out of Memory" error of Excel, sometimes causing
Excel itself to crash.
Things that I tried (and didn't work):
(assume that I have already created named ranges called myrange
for source and targrange for the target. myrange is on sheet1 and
is filled up, and targrange is on sheet3 and is empty).
1. Sub try1()
Dim myarr As Variant
myarr = Range("myrange").Value
Range("targrange").Value = myarr
End Sub
2. Sub try2()
Dim nCols As Integer, nRows As Integer
Dim rSource As Range, rTarget As Range
Dim i As Integer
Set rSource = Range("myrange")
Set rTarget = Range("targrange")
nCols = rSource.Columns.Count
nRows = rSource.Rows.Count
For i = 1 To nCols
Application.StatusBar = i
rTarget.Columns(i).Value = rSource.Columns(i).Value
Next i
Application.StatusBar = False
End Sub
Tried on many different computers (all with Excel2000, but different
Windows versions). Also with 128k and 256k RAM.
This often works first time you run it; fails on second attempt.
On machine with less memory, first attempt itself fails.
Seems like a memory leak in Excel? Anyway, even if that be so,
I am looking for a workaround.
Any help will be hugely appreciated.
Thanks in advance.
Ajay Sathe
filled up with numeric values (plain values; no formulas,
no formatting of any kind). All I want to do is
programmatically copy this data onto another worksheet
in the same workbook.
It's puzzling and frustrating to see that several
alternative approaches have failed! In all cases, the
result is "Out of Memory" error of Excel, sometimes causing
Excel itself to crash.
Things that I tried (and didn't work):
(assume that I have already created named ranges called myrange
for source and targrange for the target. myrange is on sheet1 and
is filled up, and targrange is on sheet3 and is empty).
1. Sub try1()
Dim myarr As Variant
myarr = Range("myrange").Value
Range("targrange").Value = myarr
End Sub
2. Sub try2()
Dim nCols As Integer, nRows As Integer
Dim rSource As Range, rTarget As Range
Dim i As Integer
Set rSource = Range("myrange")
Set rTarget = Range("targrange")
nCols = rSource.Columns.Count
nRows = rSource.Rows.Count
For i = 1 To nCols
Application.StatusBar = i
rTarget.Columns(i).Value = rSource.Columns(i).Value
Next i
Application.StatusBar = False
End Sub
Tried on many different computers (all with Excel2000, but different
Windows versions). Also with 128k and 256k RAM.
This often works first time you run it; fails on second attempt.
On machine with less memory, first attempt itself fails.
Seems like a memory leak in Excel? Anyway, even if that be so,
I am looking for a workaround.
Any help will be hugely appreciated.
Thanks in advance.
Ajay Sathe