Merry Christmas. I have a report that I have to do every day for 50+ employees, the problem I am tiring to solve is some times it puts a blank row (row 13) between the data.
This is what I have, but is not working. Just need it to find Employee Total: in column F and move up 1 row and to the right 1 column and if blank, hide that row. Thanks in advance for your time.
Sub HideRowsBasedOnCondition()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
' Set the worksheet variable to the desired sheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Find the last row with data in column F
lastRow = ws.Cells(ws.Rows.Count, "F").End(xlUp).Row
' Loop through each row in column F
For i = 1 To lastRow
' Check if the cell in column F contains "Employee Total:"
If ws.Cells(i, "F").Value = "Employee Total:" Then
' Move up one cell and check if the cell to the right is blank
If ws.Cells(i - 1, "G").Value = "" Then
' If blank, hide the entire row
ws.Rows(i).EntireRow.Hidden = True
End If
End If
Next i
End Sub
This is what I have, but is not working. Just need it to find Employee Total: in column F and move up 1 row and to the right 1 column and if blank, hide that row. Thanks in advance for your time.
Sub HideRowsBasedOnCondition()
Dim ws As Worksheet
Dim lastRow As Long
Dim i As Long
' Set the worksheet variable to the desired sheet
Set ws = ThisWorkbook.Sheets("Sheet1")
' Find the last row with data in column F
lastRow = ws.Cells(ws.Rows.Count, "F").End(xlUp).Row
' Loop through each row in column F
For i = 1 To lastRow
' Check if the cell in column F contains "Employee Total:"
If ws.Cells(i, "F").Value = "Employee Total:" Then
' Move up one cell and check if the cell to the right is blank
If ws.Cells(i - 1, "G").Value = "" Then
' If blank, hide the entire row
ws.Rows(i).EntireRow.Hidden = True
End If
End If
Next i
End Sub