Searching today's date on a protected sheet generates a run time error.

Heath

New Member
Joined
Jul 6, 2010
Messages
12
I have the following code generating a run time error on a protected sheet.

Error message is: Method "Goto' of 'object' _Application failed

This is used to simply lookup the current date.
The issue begins at "Application.Goto Rng, True"
Any assistance would be appreciated and thanks in advance.



Sub Todays_Date_Click()

Dim FindString As Date
Dim Rng As Range
FindString = CLng(Date)
With Sheets("Sheet Name").Range("1:")
Set Rng = .Find(What:=FindString, _
After:=.Cells(.Cells.Count), _
LookIn:=xlFormulas, _
LookAt:=xlWhole, _
SearchOrder:=xlByRows, _
SearchDirection:=xlNext, _
MatchCase:=False)
If Not Rng Is Nothing Then

Application.Goto Rng, True

Else
MsgBox "Nothing found"
End If
End With

End Sub
 

Fishboy

Well-known Member
Joined
Feb 13, 2015
Messages
4,261
Hi Heath,

Depending on how your data is laid out, try the following macro in a COPY of your workbook. You may want to change the range in which it is looking:

Code:
Sub FindDate()
For Each cell In ActiveSheet.Range("A1:Z100")
    If cell.Value = [Today()] Then
    cell.Select
    End If
Next
End Sub
 

Forum statistics

Threads
1,082,383
Messages
5,365,142
Members
400,825
Latest member
Sreekanth_21

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top