Link to home
Start Free TrialLog in
Avatar of AXISHK
AXISHK

asked on

Find the row for a input

How to write a VBA such that when a user input a given date, it will return the row number that are within the From & To date in the attached worksheet.

Tks
Test.xlsm
SOLUTION
Avatar of Phillip Burton
Phillip Burton

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Martin Liss
Add this code to a module.

Sub FindRow()

Dim lngRow As Long
Dim dteFind As Date

dteFind = InputBox("Please enter the date")
With ActiveSheet
    For lngRow = 4 To .UsedRange.Rows.Count
        If dteFind <= .Cells(lngRow, 2) Then
            MsgBox "Found in row " & lngRow
            Exit Sub
        End If
    Next
End With
MsgBox "Date " & dteFind & " not found"
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of AXISHK
AXISHK

ASKER

Tks
You're welcome and I'm glad I was able to help.

In my profile you'll find links to some articles I've written that may interest you.
Marty - MVP 2009 to 2014