Can Excel Top Gun here help a rookie out and let me know if there are a better/faster way to perform the same action?
This code works, but its slow and can take around 3-4 minutes on a laptop with i7 12th Gen processor & 64Gb RAM.
The process is to hide the entire row if the respective cell in Column A is blank, then set the row height to 40 of any cells in column A where the text string is greater than 60 characters.
This code works, but its slow and can take around 3-4 minutes on a laptop with i7 12th Gen processor & 64Gb RAM.
The process is to hide the entire row if the respective cell in Column A is blank, then set the row height to 40 of any cells in column A where the text string is greater than 60 characters.
VBA Code:
Sub CollateCOSHHSheets()
Dim r As Range, c As Range
Set r = Range("B5:B2208")
Application.ScreenUpdating = False
For Each c In r
If c.Value = "" Then
c.EntireRow.Hidden = True
Else
c.EntireRow.Hidden = False
End If
Next c
Dim lngLastRow As Long
Dim lngLoopCtr As Long
Application.ScreenUpdating = False
lngLastRow = Range("A" & Rows.Count).End(xlUp).Row
For lngLoopCtr = 1 To lngLastRow Step 1
If Len(Cells(lngLoopCtr, "A")) > 60 Then
Cells(lngLoopCtr, "A").RowHeight = 40
End If
Next lngLoopCtr
Application.ScreenUpdating = True
End Sub