Forum Discussion
skolawol05
Apr 26, 2024Copper Contributor
how to hide the entire row on specific cell value
I am creating excel template for a report in Oracle HCM. I need to hide any row that are coming with a specific cell values. Could this be accomplished with the template?
NikolinoDE
Apr 27, 2024Platinum Contributor
Sub HideRowsBasedOnCellValue()
Dim ws As Worksheet
Dim lastRow As Long
Dim cell As Range
Dim hideValue As String
' Set the worksheet
Set ws = ThisWorkbook.Sheets("Sheet1") ' Change "Sheet1" to your sheet name
' Define the cell value to hide rows
hideValue = "Hide" ' Change "Hide" to your specific cell value
' Find the last row with data in column A
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
' Loop through each row
For Each cell In ws.Range("A1:A" & lastRow)
' Check if the cell value matches the value to hide rows
If cell.Value = hideValue Then
' Hide the entire row
cell.EntireRow.Hidden = True
End If
Next cell
End SubVBA Code ist untested, please backup your file.