Does anyone know a alternate code to do the following....this has been running really slowly.

iowitz

New Member
Joined
Nov 19, 2013
Messages
17
Changing all the files row height to "15" above the top of the letters.


Sub test()
Dim i As Long, startRow As Long, endRow As Long, rowHeightIncrease As Long

Rows.AutoFit

startRow = 2
endRow = Cells(Rows.Count, 1).End(xlUp).Row

rowHeightIncrease = 15

For i = startRow To endRow
Rows(i).RowHeight = Rows(i).RowHeight + rowHeightIncrease
Next i
End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Changing all the files row height to "15" above the top of the letters.


Sub test()
Dim i As Long, startRow As Long, endRow As Long, rowHeightIncrease As Long

Rows.AutoFit

startRow = 2
endRow = Cells(Rows.Count, 1).End(xlUp).Row

rowHeightIncrease = 15

For i = startRow To endRow
Rows(i).RowHeight = Rows(i).RowHeight + rowHeightIncrease
Next i
End Sub
If the rows are currently all the same height, you could do this in place of the loop...

Rows(startRow & ":" & endRow).RowHeight = Rows(startRow).RowHeight + rowHeightIncrease

However, if the current heights can vary, then the only thing I can think of is to put this before your For statement...

Application.ScreenUpdating = False

and this after the Next statement...

Application.ScreenUpdating = True
 
Upvote 0
Can you show me where in the code to put exactly?
Shown in red...

Rich (BB code):
Sub test()
  Dim i As Long, startRow As Long, endRow As Long, rowHeightIncrease As Long

  Rows.AutoFit

  startRow = 2
  endRow = Cells(Rows.Count, 1).End(xlUp).Row

  rowHeightIncrease = 15

  Application.ScreenUpdating = False
  For i = startRow To endRow
    Rows(i).RowHeight = Rows(i).RowHeight + rowHeightIncrease
  Next i
  Application.ScreenUpdating = True

End Sub
 
Upvote 0

Forum statistics

Threads
1,217,385
Messages
6,136,277
Members
450,001
Latest member
KWeekley08

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top