Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Macro Fails
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
Reply to thread
Message
[QUOTE="Sandy, post: 6339599"] Hello I have a monthly report that has 31 rows of data for each day. The following code is used to display only the current day. The first cell in Column AG for each day contains the date and the other cells for that day in col AG are blank. The code works except for the the 31st of the months that have 31 days. The code is failing on Rows(rng.Row & ":" & rng.Row + 30).Hidden = False and it appears as though the code is trying to hide all rows of the sheet. Does anyone see what may be causing this, and how do I fix it? Private Sub CommandButton1_Click() Dim FindString As Date Dim rng As Range Application.ScreenUpdating = False FindString = Date Columns("AG:AG").Select Selection.EntireColumn.Hidden = False Rows(3 & ":" & Rows.Count).Hidden = False With Sheets("MySheet").Range("AG:AG") Set rng = .Find(What:=FindString, _ After:=.Cells(.Cells.Count), _ LookIn:=xlValues, _ LookAt:=xlWhole, _ SearchOrder:=xlByRows, _ SearchDirection:=xlNext, _ MatchCase:=False) If Not rng Is Nothing Then Rows(3 & ":" & Rows.Count).Hidden = True Rows(rng.Row & ":" & rng.Row + 30).Hidden = False Application.Goto rng, True Else MsgBox "Date Not Found" End If End With Columns("AG:AG").Select Selection.EntireColumn.Hidden = True Application.ScreenUpdating = True Range("C1").Select End Sub [/QUOTE]
Verification
Post reply
Forums
Archive
Newsgroup Archive
Excel Newsgroups
Excel Programming
Macro Fails
Top