Find Corresponding Date in Sheet Based on Corresponding Date in Sheet1("A5")

OilEconomist

Active Member
Joined
Dec 26, 2016
Messages
439
Office Version
  1. 2019
Platform
  1. Windows
Thanks in advance and I will post feedback for proposed solutions.

Here is my code thus far.

Code:
Sub FindDate2()
        
        Dim DT As Date, VR As Variant, CL As Long
        
        DT = Sheets("Sheet1").CDate(Cells(5, 1))
                   
        Set VR = Sheets("Sheets").Range("3:3").Find(DT, , , xlWhole)
        
        If Not DT Is Nothing Then
            CL = DT.Column
        
        Else
        
        Exit Sub
    
        End If
    
End Sub
For the date located in cell A5 of sheet "Sheet1", I am trying to find the corresponding column number/cell address within Row 3 of "Sheet2" with that same date.

The date in cell A5 of "Sheet1" is a hard coded value with the format "4/1/2019".

The dates in Row 3 of "Sheet2" are formulas after the first date entered.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
The date formats on both sheets must be mm / dd / yyyy
If on sheet1, in cell A5 you have a date, then we simply take that value.

Try

Code:
Sub FindDate2()
    Dim DT As Date, VR As Range, CL As Long
    
[COLOR=#0000ff]    DT = Sheets("Sheet1").Cells(5, 1).Value[/COLOR]
    Set VR = Sheets("Sheet2").Range("3:3").Find(DT, LookIn:=xlValues, lookat:=xlWhole)
    If Not VR Is Nothing Then
        CL = VR.Column
        MsgBox "Column :  " & CL
    Else
        MsgBox "Not found"
    End If
End Sub


If you have a text in cell A5 then you have to convert the text to date:
DT = cdate(Sheets("Sheet1").Cells(5, 1).Value)
 
Upvote 0
Last edited:
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,306
Members
452,633
Latest member
DougMo

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