Hide rows based on value in cell G2

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
110
Good afternoon, I am using windows 7, and excel 2007. I want to hide rows bases on a value in cell G2 which is a date field

Example, if G2 is greater than 11/16/2011 then hide rows 1969 through 2032.

Is this possible? Thank you so much for all of you hard work. You folks have helped me out of many bad situations.

I will await a reply.

Redd
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Maybe with a change event, this one is based purely on your question.

Right click the sheet tab, view code, then copy / paste.

Code:
Private Sub Worksheet_Change(ByVal Target As Range)
[A1969:A2032].EntireRow.Hidden = ([G2].Value > "11/16/2011")
End Sub
 
Upvote 0
followed instructions, does not work. Rows still there. Could it be because of other code I have on the form, that has to do with password etc.? See following code I already have


Private Sub Worksheet_Change(ByVal Target As Range)
[A1969:A2032].EntireRow.Hidden = ([G4].Value > "11/16/2011")
End Sub

Private Sub CommandButton1_Click()
On Error Resume Next
Range("a13:q3500").Value = vbNullString
On Error GoTo 0
End Sub

Private Sub CommandButton2_Click()
Dim searchthis As String, Found As Range
Me.Unprotect Password:="123"
searchthis = InputBox("Type Number.", "Property Search")
searchthis = searchthis & "*"
Set Found = Range("A:A,c:c").Find(What:=searchthis, LookIn:=xlFormulas, LookAt:=xlWhole)
If Not Found Is Nothing Then Found.Select
Me.Protect Password:="123"
End Sub
Private Sub CommandButton3_Click()
Me.Unprotect Password:="123"
Application.Goto Range("a8"), True
Me.Protect Password:="123"
End Sub

Private Sub CommandButton4_Click()
On Error Resume Next
Range("a13:q3500").Value = vbNullString
On Error GoTo 0
Me.Unprotect Password:="123"
Application.Goto Range("a13"), True
Me.Protect Password:="123"
Application.DisplayAlerts = False
Application.Quit
Application.Quit
End Sub
 
Upvote 0
I fixed it, thanks


Private Sub Worksheet_Change(ByVal Target As Range)
Me.Unprotect Password:="123"
[A1969:A2032].EntireRow.Hidden = ([G4].Value > "11/16/2011")
Me.Protect Password:="123"
End Sub
 
Upvote 0
well I thought it fixed it. It works, only if the date in the code is before 1/1/2012.


I took my field G4 and made it add 50 days to make it 1/7/2012 and the date in the code as 1/1/2012 and it did not work.
 
Upvote 0
Use the format "01/01/2012" in the code then it works.
 
Upvote 0

Forum statistics

Threads
1,214,618
Messages
6,120,544
Members
448,970
Latest member
kennimack

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