Hello,
This is my first time trying to tackle things in excel using VBA, so some of the items were shamelessly stolen off of various message boards and youtube tutorials and modified to fit my needs. However, this seems to be unreliable and very slow. It takes about 20 seconds to update and doesn't work every time. My goal was to hide rows that were 0's across the board and not blank (12 columns contain data). Any ideas? Thanks for the help!
This is my first time trying to tackle things in excel using VBA, so some of the items were shamelessly stolen off of various message boards and youtube tutorials and modified to fit my needs. However, this seems to be unreliable and very slow. It takes about 20 seconds to update and doesn't work every time. My goal was to hide rows that were 0's across the board and not blank (12 columns contain data). Any ideas? Thanks for the help!
Code:
Private Sub Worksheet_Change(ByVal Target As Range)'HideRows()
Sheet2.Unprotect Password:="----"
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Rows("5:900").Hidden = False
For Each c In Range("b6:b800,c6:c800,d6:d800,e6:e800,f6:f800,g6:g800,h6:h800,i6:i800,j6:j800,k6:k800,l6:l800,m6:m800,n6:n800")
If c.Value = 0 And c.Value <> "" _
And c.Offset(0, 1).Value = 0 And c.Offset(0, 1).Value <> "" _
And c.Offset(0, 2).Value = 0 And c.Offset(0, 2).Value <> "" _
And c.Offset(0, 3).Value = 0 And c.Offset(0, 3).Value <> "" _
And c.Offset(0, 4).Value = 0 And c.Offset(0, 4).Value <> "" _
And c.Offset(0, 5).Value = 0 And c.Offset(0, 5).Value <> "" _
And c.Offset(0, 6).Value = 0 And c.Offset(0, 6).Value <> "" _
And c.Offset(0, 7).Value = 0 And c.Offset(0, 7).Value <> "" _
And c.Offset(0, 8).Value = 0 And c.Offset(0, 8).Value <> "" _
And c.Offset(0, 9).Value = 0 And c.Offset(0, 9).Value <> "" _
And c.Offset(0, 10).Value = 0 And c.Offset(0, 10).Value <> "" _
And c.Offset(0, 11).Value = 0 And c.Offset(0, 11).Value <> "" _
And c.Offset(0, 12).Value = 0 And c.Offset(0, 12).Value <> "" _
Then Rows(c.Row).Hidden = True
Next
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
Sheet2.Protect Password:="----"
End Sub