Is there a way to hide or deactivate rows?

rohnn

New Member
Joined
Feb 2, 2023
Messages
2
Office Version
  1. 2021
Platform
  1. Windows
Hi everybody.

I have a an app that pulls information dynamically from an excel sheet.

In this sheet, in each row, I have available cars for renting. And the apps pulls all necessary information from the sheet and presents it to the user. The thing is that the data is always changing and I don't want to keep erasing and writing back cars that are available for rent or not.

So what I'm looking for is for a way to hide or "deactivate" rows, but not from anyone working on the sheet, but from the script that it's trying to pull information from the sheet, so it would be like there's no data in some rows.

I saw a sheet that had a "active" column, with a TRUE or FALSE value, so that I could mark each row as active(TRUE) or not active (FALSE), but unfortunately it was just a screenshot and I couldn't see how it worked. 2023-02-02-10-23-53-Copy-of-Google-Sheets-Template-for-Pizza-Ordering-and-Delivery-Messenger-Bot-G hosted at ImgBB

Any help would be greatly appreciated. Thanks.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
If you have a "flag" value in a column (could be whatever you want but I'd suggest 0 for False and -1 for True). 2 examples
If the row contains 0 it will not hide (Hidden = 0 = False, not hidden). If the row contains -1 it will be hidden.
VBA Code:
Sheets("4").Rows(10).EntireRow.Hidden = Sheets("4").Range("B10")
so the hiding code line can be that simple.

If the flag value is something else, then
VBA Code:
If Sheets("4").Range("B9") = "YourFlagValueGoesHere" Then
   Sheets("4").Rows(9).EntireRow.Hidden = True
End If
Of course that is just a simple answer to your question. To restore hidden rows, you could just select the whole sheet via top left sheet selector, right click and choose unhide from the context menu. I used row values 9 and 10 to test but you would want to loop over all the rows in a particular column that would contain your flag value.
 
Upvote 0
Solution
If you have a "flag" value in a column (could be whatever you want but I'd suggest 0 for False and -1 for True). 2 examples
If the row contains 0 it will not hide (Hidden = 0 = False, not hidden). If the row contains -1 it will be hidden.
VBA Code:
Sheets("4").Rows(10).EntireRow.Hidden = Sheets("4").Range("B10")
so the hiding code line can be that simple.

If the flag value is something else, then
VBA Code:
If Sheets("4").Range("B9") = "YourFlagValueGoesHere" Then
   Sheets("4").Rows(9).EntireRow.Hidden = True
End If
Of course that is just a simple answer to your question. To restore hidden rows, you could just select the whole sheet via top left sheet selector, right click and choose unhide from the context menu. I used row values 9 and 10 to test but you would want to loop over all the rows in a particular column that would contain your flag value.
Thank you! I will try that.
 
Upvote 0

Forum statistics

Threads
1,215,025
Messages
6,122,731
Members
449,093
Latest member
Mnur

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