miless2111s
Active Member
- Joined
- Feb 10, 2016
- Messages
- 273
I have some code which outputs many values to many cells (around 16 columns and 1000 rows) which takes around a minute to run.
I have been thinking that it was the calculations which were making it slow and have been investigating other options with this forum's help but writing a calculation free script to put out the same sort of volume of information produced a long run time so I suspect I also need to find a way to more quickly output information.
This is the test code:
As I am a beginner at all this I wonder if I am going about this in a slow way? Anyone got any ideas? Note that after the first run this output will not all change every time it is run so I don't know if that something that might help in some way???
Many thanks
Miles
I have been thinking that it was the calculations which were making it slow and have been investigating other options with this forum's help but writing a calculation free script to put out the same sort of volume of information produced a long run time so I suspect I also need to find a way to more quickly output information.
This is the test code:
Code:
Sub massive_print()
Dim wb As Workbook
Dim ws As Worksheet
Dim trial As String
Dim t As Single
Application.ScreenUpdating = False
t = timer
Set wb = ActiveWorkbook
Set ws = wb.Sheets("trial_print")
trial = "test entry"
For i = 1 To 1031
ws.Range("a" & i).Value = trial
ws.Range("b" & i).Value = trial
ws.Range("c" & i).Value = trial
ws.Range("d" & i).Value = trial
ws.Range("g" & i).Value = trial
ws.Range("h" & i).Value = trial
ws.Range("i" & i).Value = trial
ws.Range("j" & i).Value = trial
ws.Range("l" & i).Value = trial
ws.Range("m" & i).Value = trial
ws.Range("n" & i).Value = trial
ws.Range("t" & i).Value = trial
ws.Range("u" & i).Value = trial
ws.Range("v" & i).Value = trial
ws.Range("w" & i).Value = trial
ws.Range("ae" & i).Value = trial
Next i
ActiveWorkbook.Sheets("Test_scores").Range("h10").Value = timer - t
ActiveWorkbook.Sheets("Test_scores").Range("h09").Value = "time to print 1000 lines:"
Application.ScreenUpdating = True
End Sub
As I am a beginner at all this I wonder if I am going about this in a slow way? Anyone got any ideas? Note that after the first run this output will not all change every time it is run so I don't know if that something that might help in some way???
Many thanks
Miles
Last edited: