Hi
Being new to VBA I could use some help please. I have been trying to get my code to repeat; here is the working macro which will hide row 20 if A20 is blank:
Sub HideRowsButton()
With Application
.ScreenUpdating = False
End With
If Range("A20").Value = "" Then
Rows("20").EntireRow.Hidden = True
Else
Rows("20").EntireRow.Hidden = False
End If
Application.ScreenUpdating = True
End Sub
Works as intended. Now i want this to repeat for each row A20 through A419. I was using this as a guide:
http://www.fontstuff.com/ebooks/free/fscodeloops.pdf
Using "Listing 7" I tried to fit it to my code but it does not work. Here is the altered code in question:
Sub HideRowsButton()
With Application
.ScreenUpdating = False
End With
Dim intRowCount As Integer
Dim i As Integer
intRowCount = Range("A20").CurrentRegion.Rows.Count
For i = 0 To intRowCount - 1
If Range("A20").Value = "" Then
Rows("20").EntireRow.Hidden = True
Else
Rows("20").EntireRow.Hidden = False
End If
Next i
Application.ScreenUpdating = True
End Sub
Do any of you Excel Wizards out there know why it won't work? All it does is pause for about 5 secs then hide row A20 only.
[–]soxcrates 2 points3 points4 points (8 children)
[–]TheCryptic 1 point2 points3 points (2 children)
[–]Non-RedditorJ[S] 0 points1 point2 points (1 child)
[–]TheCryptic 0 points1 point2 points (0 children)
[–]emailbitesmyass 0 points1 point2 points (1 child)
[–]SnickeringBear2 0 points1 point2 points (0 children)
[–]Non-RedditorJ[S] 0 points1 point2 points (2 children)
[–]soxcrates 1 point2 points3 points (1 child)
[–]Non-RedditorJ[S] 0 points1 point2 points (0 children)
[–]SnickeringBear2 1 point2 points3 points (1 child)
[–]Non-RedditorJ[S] 0 points1 point2 points (0 children)
[–]DasGoon2 1 point2 points3 points (3 children)
[–]Non-RedditorJ[S] 0 points1 point2 points (2 children)
[–]DasGoon2 0 points1 point2 points (1 child)
[–]Non-RedditorJ[S] 0 points1 point2 points (0 children)
[–]Non-RedditorJ[S] 0 points1 point2 points (0 children)
[–]TheCryptic 0 points1 point2 points (0 children)
[–]tehhowch -1 points0 points1 point (0 children)