Hide rows based on value in cell G2

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
91
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
 

Some videos you may like

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,903
Office Version
  1. 365
Platform
  1. Windows
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
 

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
91
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
 

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
91
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
 

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
91

ADVERTISEMENT

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.
 

jasonb75

Well-known Member
Joined
Dec 30, 2008
Messages
11,903
Office Version
  1. 365
Platform
  1. Windows
Use the format "01/01/2012" in the code then it works.
 

reddcannon

Board Regular
Joined
Aug 11, 2011
Messages
91
I bow to the great one. Works. Have a wonderful day and thanks again for everything.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,371
Messages
5,595,784
Members
414,020
Latest member
Meghdad

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
Top