I want to loop through a range. If any data exists on the row of the range from Column C over to the last column in use, I want to hide the row.
I have questions about null and zero values in the cells. Cells can have either in a row of data. I am hiding zero values but I am assigning a zero value via a function for some cells.
Using code from a post dealing with a similar problem, this is what I came up with.
(Sorry if I was supposed to put this in tags. I didn't see the tags for the code on this forum.)
Dim LastRow, LastCol, LastDataRow, R, TotalRows As Long
Dim WeeklyValues As Range
'Find the last row, column and last cell of the worksheet.
LastRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row
LastCol = ActiveSheet.Cells(1, Columns.Count).End(xlToLeft).Column
LastDataRow = ActiveSheet.Cells(LastRow - 2)
'Run the loop to determine if there are any values within the specified range.
'If there are no values in any cell of a row then hide the row.
ActiveSheet.Range("C4").Resize(LastDataRow, LastCol).Select
Selection.Name = WeeklyValues
TotalRows = Range("V" & LastDataRow)
For R = 4 To TotalRows
ActiveSheet.Range("C" & R).Resize(, LastCol).Select
If Cells(Selection).Value = 0 Then
Rows(R).Hidden = True
End If
Next R
Please offer suggestions for my code.
Thanks in advance.
Bookmarks