Double click to open dialog box, enter date then search Column A

Ironman

Well-known Member
Joined
Jan 31, 2004
Messages
1,069
Office Version
  1. 365
Platform
  1. Windows
Hi

The below code opens the general search box when I double click a defined cell.

VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Target.Column = 1 And Target.Row = 11 Then
Application.Dialogs(xlDialogFormulaFind).Show
End If
End Sub

I want to make this more specific so I just get a dialog box to enter d/mm/yyyy and then search Column A (although the above code does the job, it's not specific to Column A so I don't know if it's necessary to specify Column A with what I want to do now?).

Help appreciated, many thanks.
 
Last edited:

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.
Have a look at this thread here: Value find Dialog Box Macro

which may help you or you could use the Range.Find method

VBA Code:
Set foundcell = Columns(1).Find(search, LookIn:=xlFormulas, lookat:=xlWhole)

Dave
 
Upvote 0
Many thanks Dave, that was an interesting alternative. However, I would have thought there must be a way of creating an input box with dd mm yyyy that I can complete and search?
 
Upvote 0
Hi,
Dates using Range.Find can be a little tricky but try following & see if does what you want

VBA Code:
Sub IronMan()
    Dim foundcell   As Range
    Dim search      As Variant
    
    Do
    search = InputBox("Enter Search Date", "Search Date")
    'cancel pressed
    If StrPtr(search) = 0 Then Exit Sub
    Loop Until IsDate(search)
    
    search = DateValue(search)
    
    Set foundcell = Columns(1).Find(search, LookIn:=xlFormulas, lookat:=xlWhole)
    If Not foundcell Is Nothing Then
        'found
        MsgBox foundcell.Address
    Else
        'not found
        MsgBox search & Chr(10) & "Not Found"
    End If
End Sub

Note: Range is unqualified & assumes search sheet is the activesheet.

Dave
 
Upvote 0
Solution
Thanks again Dave - that's very good! I was wondering if there was a way to make it slicker by having a 3 box format that I can input dd mm yyyy into rather than free text and having to enter / / ?
 
Upvote 0
Standard InputBox only has one text entry field to have dd mm yyyy fields you would need to create a UserForm

However, you can just enter dd mm yyyy without / (back slash) in the InputBox solution I provided & it should still work for you.

Dave
 
Upvote 0
Ahh I hadn't realised that, that'll be fine - many thanks once again Dave.
 
Upvote 0

Forum statistics

Threads
1,214,528
Messages
6,120,065
Members
448,942
Latest member
sharmarick

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