PDA

View Full Version : Looping and Transposing in excel



Georgekid
11-16-2011, 10:55 PM
Hello,

So far I've managed to piece together this code below by hacking at other code and trial and error. I think I have reached the limit of what I can cobble together on my own, any help would be much appreciated.

The code currently works, albeit a bit slowly. Each iteration some inputs are changed on the project costs sheet, calculations are done in a column(k2:k6) and these numbers outputted to the project costs sheet, starting from row 36 onwards.

I'm about to add extra calulations and iterations, I understand that loops are slow and nasty but I'm unsure where to go replacing them and with what? I'll also be having a few more outputs so I'd like to change the way I'm pulling through k2:k6.


Sub Macro2()
Range("D36:H55").Select
Selection.ClearContents


Application.ScreenUpdating = False

Do Until i = 20
i = i + 1
Sheets("costings output").Range("C1").Value = i
Cells(35 + i, 4).Value = Sheets("project costs").Range("k2").Value
Cells(35 + i, 5).Value = Sheets("project costs").Range("k3").Value
Cells(35 + i, 6).Value = Sheets("project costs").Range("k4").Value
Cells(35 + i, 7).Value = Sheets("project costs").Range("k5").Value
Cells(35 + i, 8).Value = Sheets("project costs").Range("k6").Value

Loop
Application.ScreenUpdating = True
End Sub


Cheers for any pointers

George