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
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
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
 
Upvote 0

Forum statistics

Threads
1,214,918
Messages
6,122,255
Members
449,075
Latest member
staticfluids

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