Forum Discussion
Excel autohide row based on 4 cells if blank
This would require VBA, so it will only work in the desktop version of Excel for Windows and Mac.
If that is OK, please provide more detailed information.
- AlanatabzApr 08, 2025Copper Contributor
If Low Low Alarm, Low Alarm, High Alarm, and High High Alarm is not a number, then hide the row
If for example Low Low Alarm has 0 or another number then the row must be seen
The column can be !!! or blank, for it to be visble at least one number muct be present in one or more of the four columns
Thanks for your reply
- KevinCarterApr 08, 2025Copper Contributor
For Excel Online (without VBA), you'll need to use Power Automate integration to achieve automatic row hiding when four columns are blank. Here's how to set it up:
1. Prepare Your Excel File
- Save your workbook to OneDrive/SharePoint (required for Power Automate integration)
- Identify the 4 columns to monitor (e.g., Columns A, B, C, D)
2. Create a Power Automate Flow
- Go to https://make.powerautomate.com/
- Create a new Scheduled Cloud Flow
- Trigger: Choose "Recurrence" (e.g., run every 15 minutes)
- Add Step: List rows present in a table (Excel Online connector)
- Select your file and worksheet
- Add Step: Apply to each (loop through rows)
- Use this formula in "Condition" to check blank cells:@and(empty(item()?['ColumnA']), empty(item()?['ColumnB']), empty(item()?['ColumnC']), empty(item()?['ColumnD']))
- Add Step: Run script (Office Scripts - limited Excel Online automation)
- Use this TypeScript code:function main(workbook: ExcelScript.Workbook) { let sheet = workbook.getActiveWorksheet(); let range = workbook.getSelectedRange(); range.getEntireRow().setRowHidden(true); }
- AlanatabzApr 09, 2025Copper Contributor
Is there a way to do this, in Excel running on a local machine?
- KevinCarterApr 12, 2025Copper Contributor
if you are running it on a local machine, then VBA would be better
Dim NextRun As Double
Sub ScheduleRowHiding()
NextRun = Now + TimeValue("00:15:00") ' 15-minute interval
Application.OnTime NextRun, "CheckAndHideRows"
End SubSub CheckAndHideRows()
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet1") ' Change to your sheet name
Dim lastRow As Long
lastRow = ws.Cells(ws.Rows.Count, "A").End(xlUp).Row
Application.ScreenUpdating = False
On Error GoTo CleanUp
For i = 1 To lastRow
If IsRowEmpty(ws, i) Then
ws.Rows(i).Hidden = True
End If
Next i
CleanUp:
Application.ScreenUpdating = True
ScheduleRowHiding ' Reschedule
End SubFunction IsRowEmpty(ws As Worksheet, rowNum As Long) As Boolean
IsRowEmpty = Application.CountA(ws.Range("A" & rowNum & ":D" & rowNum)) = 0
End FunctionSub CancelSchedule()
On Error Resume Next
Application.OnTime NextRun, "CheckAndHideRows", , False
End Sub