I need to hide an entire row if a particular field has 2011 in it. Is this possible?
I need to hide an entire row if a particular field has 2011 in it. Is this possible?
Last edited by jeffreybrown; 02-15-2013 at 09:12 PM.
Sure, this is possible, but a few more details would help...
When do you want the hide to happen? Only when you press a button or what?
How or when do you want the rows unhidden?
HTH
Regards, Jeff
Here is some code that I use to accomplish this, although I have the criteria to hide as a variable that is populated by an Inputbox that way I can use it in more that one spreadsheet.
This will work over multiple columns.
If you highlight only column B, run the code and enter 2011 you will have 1001 to 1009.
If you highlight columns B, C, and D, run the code and enter 2011 you will have 1001, 1003, 1005, 1007, 1009
I hope this helps you out.
HideRowsbasedonUserSelectionandInput.xls
I want to hide an entire row once a particular column of said row has 2011. Example: I want to hide row 5 once "G5" contains 2011 (btw, it won't only be 2011 - it could be 05/31/2011, 06/30/2011, etc.) I want this to be true for the entire spreadsheet - if G-whatever the corresponding row is contains 2011, then I want it hidden.
Hopefully this makes more sense.
Thank you for your assistance.
I have made changes to the code so that if 2011 or a date such as 05/01/2011 is in a cell then the entire row will be hidden.
HideRowsbasedonUserSelectionandInput(MatchStringorYear).xlsm
I have also changed a couple of cells to the month/day/year format. I hope this helps.![]()
Sub Macro1() 'The user has to have a range selection or nothing will happen Dim Strng As String Strng = InputBox("Enter the string to be hidden") Application.ScreenUpdating = False On Error Resume Next Selection.SpecialCells(xlCellTypeConstants, 23).Select For Each cell In Selection If cell.Value = Strng Or Year(cell) = Strng Then cell.EntireRow.Hidden = True Else End If Next cell Application.ScreenUpdating = True End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks