VBA - Automatic hide entire rows depend on a cell value

JulioTheLess

New Member
Joined
Dec 13, 2021
Messages
17
Office Version
  1. 2016
Platform
  1. Windows
Auto Hide of cell.png


I was trying to make auto hiding of rows depends on the cell value, for example I typed no. "5", the entire rows for nos. 6 and 7 will be hidden.
 

Excel Facts

What is the shortcut key for Format Selection?
Ctrl+1 (the number one) will open the Format dialog for whatever is selected.
I'm planning to have allotted cell for that on a different sheet wherein users easily input the no. of desired rows.
Auto hide cell 2.png


Like this one sir.
Where are you going the type No. 5 in a certain cell for example?
 
Upvote 0
I'm planning to have allotted cell for that on a different sheet wherein users easily input the no. of desired rows.View attachment 53497

Like this one sir.
aUTO HIDE CELL 3.png
aUTO HIDE CELL 4.png


Here will be "input data sheet" S6 where users input the desire number, then the "summary" sheet will be the result for macro auto hide of entire rows.

Thanks! a lot
 
Upvote 0
Well
as per your post #1
Put this in input Data code
And type no in J1

will hide rows 6& 7 in sheet1
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Cells(6, 19)) Is Nothing Then
        Sheets("sheet1").Rows(Target + 1).Resize(2).EntireRow.Hidden = True
    End If
End Sub
 
Upvote 0
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Cells(6, 19)) Is Nothing Then
        Sheets("sheet1").Rows(Target + 1).Resize(2).EntireRow.Hidden = True
    End If
End Sub

[/QUOTE]
its seems not working accordingly since, i was not able to show that the there are blank rows right after each nos.
 
Upvote 0
Well
as per your post #1
Put this in input Data code
And type no in J1

will hide rows 6& 7 in sheet1
VBA Code:
Private Sub Worksheet_Change(ByVal Target As Range)
    If Not Intersect(Target, Cells(6, 19)) Is Nothing Then
        Sheets("sheet1").Rows(Target + 1).Resize(2).EntireRow.Hidden = True
    End If
End Sub
its seems not working accordingly since, i was not able to show that the there are blank rows right after each nos.
 
Upvote 0

Forum statistics

Threads
1,215,666
Messages
6,126,106
Members
449,292
Latest member
Mario BR

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top