title: Excel VBA running really slow
body: <p>I have what I think is a pretty short VBA excel script that basically copies data to another sheet if there is data there and then displays it how I need it displayed to print.</p>
  
  <p>It runs really slow</p>
  
  <p>As you can see I have tried to turn off auto calculation and screen updating. This I think speeds it up a little. But it still take several minutes on what I think should take a second.</p>
  
  <pre><code>    Sub Button2_Click()
  
  Application.Calculation = xlCalculationManual
  Application.ScreenUpdating = False
  With Worksheets("sheet2").PageSetup
          .PaperSize = xlPaperStatement
          .Orientation = xlLandscape
          .LeftMargin = Application.InchesToPoints(1.5)
          .RightMargin = Application.InchesToPoints(0)
          .TopMargin = Application.InchesToPoints(1.25)
          .BottomMargin = Application.InchesToPoints(0)
          .HeaderMargin = Application.InchesToPoints(0)
          .FooterMargin = Application.InchesToPoints(0)
          .Zoom = 100
          .PrintErrors = xlPrintErrorsDisplayed
  End With
  
  
  
  Dim rows, colum, length, i, a, b, c As Integer
  length = Worksheets("Sheet1").Cells(Worksheets("Sheet1").rows.Count, "A").End(xlUp).Row
  i = 1
      For rows = 3 To length
          For colum = 4 To 6
              If colum = 5 Then
          GoTo NextIteration
              End If
              If IsEmpty(Worksheets("Sheet1").Cells(rows, colum)) Then
              GoTo NextIteration
              Else
              Worksheets("Sheet2").rows(i).RowHeight = 90
              Worksheets("Sheet2").rows(i + 1).RowHeight = 3.6
              Worksheets("Sheet2").rows(i + 2).RowHeight = 79.6
              Worksheets("Sheet2").rows(i + 3).RowHeight = 93.2
              a = Len(Worksheets("Sheet1").Cells(rows, colum))
              b = InStr(1, Worksheets("Sheet1").Cells(rows, colum), " ")
              c = a - b + 1
              Worksheets("Sheet2").Cells(i, 2).Value = Mid(Worksheets("Sheet1").Cells(rows, colum), InStr(1, Worksheets("Sheet1").Cells(rows, colum), " "), c)
              Worksheets("Sheet2").Cells(i + 2, 2).Value = Format(Worksheets("Sheet1").Cells(rows, 1), "Medium Time")
              i = i + 4
              End If
  NextIteration:
          Next colum
      Next rows
  
  Worksheets("Sheet2").Columns("A:A").ColumnWidth = 13
  Worksheets("Sheet2").Columns("B:B").ColumnWidth = 77
  Worksheets("Sheet2").Columns("B:B").Font.Name = "David"
  
  Application.Calculation = xlCalculationAutomatic
  Application.ScreenUpdating = True
  End Sub
  </code></pre>
  
  <p>Is it possible that having the view mode set to page layout would make it slow down?</p>
  
  <p>I have switched it back to normal view mode and it works almost instantly.</p>