View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
pete pete is offline
external usenet poster
 
Posts: 88
Default Populating a Temporary Array

Sorry, my fault for not being clear. What you have given
me is pretty much what I am using (My code is almost
identical to Jim's post), but it runs slowly. I had
thought that perhaps not writing anything to the
worksheet until the end would be quicker and hence I was
playing with temp arrays. The first single cell example
was one from a book by John Walkenbach and I was just
trying to see if I could do something similar row by row
as opposed to cell by cell. I am not using this cell by
cell method in my workbook.

Thanks


-----Original Message-----
Call me lazy but trying to understand your code is

giving
me a headache (iterating two dimensional arrays.. ugh),
but from your description, I assume you are

recalculating
your first sheet after transposing 1 row.

i.e. the loop does:

1) Read first range (h1:h256)
2) Transpose to (A2:IV2)
3) Recalculate

-- next iteration

If this is what you are doing, then you can try the
following code and you should see a significant
performance gain over the single cell way you say you

are
doing it.

It annoyingly flickers during this as it constantly
switches worksheets. Don't know how to avoid that.

---begin code-------------------------------------------

Sub TranData()

Dim rng1 As Range
Dim rng2 As Range

Dim ws1 As Worksheet
Dim ws2 As Worksheet

Dim myRange As String
Dim wRow As Integer 'Write Row

Set ws1 = ActiveSheet
Set ws2 = ActiveWorkbook.Worksheets("Sheet2")

Set rng1 = ws1.Range("h1:h256")


For wRow = 2 To 1001
myRange = "A" & wRow & ":IV" & wRow
Set rng2 = ws2.Range(myRange)

rng1.Copy '1)
rng2.PasteSpecial xlPasteValues, _
xlPasteSpecialOperationNone, ,

True '2
ws1.Calculate '3
Next wRow

End Sub

---end code-------------------------------------------

.