find a particular date in another sheet

macangc

Board Regular
Joined
Mar 28, 2006
Messages
140
Office Version
  1. 365
Hi there

Relative newcomer to Visual Basic and i would like some help with the following if possible

I have a cell that i will enter a date into and when i click the button below it will find the same date in another sheet, then move down one cell and across one.

Thanks in advance
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
58,302
Office Version
  1. 365
Platform
  1. Windows
Welcome to the board!

Much of the code you need can be obtained using the macro recorder. Give this a go. Obviously, you will need to change the sheet names and range to suit your worksheet.
Code:
Sub MyFind()

'   Capture value to find from sheet 1 
    Dim myFindDate As Date
    myFindDate = Sheets("Sheet1").Range("F1")
    
'   Find value on sheet 2
    Sheets("Sheet2").Activate
    On Error GoTo err_chk
    Cells.Find(What:=myFindDate, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
        :=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
        False).Offset(1, 1).Activate
    On Error GoTo 0
    
    Exit Sub
'   Error handling if it cannot find value
err_chk:
    If Err.Number = 91 Then
        Sheets("Sheet1").Activate
        MsgBox "Cannot find the value " & myFindDate
    Else
        MsgBox Err.Number & ": " & Err.Description
    End If
    
End Sub
 

macangc

Board Regular
Joined
Mar 28, 2006
Messages
140
Office Version
  1. 365
Thanks very much, that worked a treat. Appreciate the help
 

Forum statistics

Threads
1,136,579
Messages
5,676,652
Members
419,638
Latest member
GlenMc52

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