+ Reply to Thread
Results 1 to 11 of 11

search dates and text

  1. #1
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    search dates and text

    Please could someone post how to search for text and dates within a database. I have a spreadsheet that can search for any part of text but I cannot search by date.

    The existing code is as follows:

    Private Sub Search_Click()
    Dim LR As Long, Val As String, cell As Range, Rng As Range, Code As Boolean
    Dim dSh As Worksheet, v

    'Setup
    Sheets("SEARCH-HERE").Activate
    If Range("E2") <> "" Then
    Val = Range("E2").Value & ""
    Code = True
    ElseIf Range("E3") <> "" Then
    Val = Range("E3").Value
    Code = False
    Else
    MsgBox "Please enter ONE search criteria and try again."
    Exit Sub
    End If
    Application.ScreenUpdating = False
    Application.EnableEvents = False
    Set dSh = Sheets("DATABASE")
    Range("B10:J200").ClearContents

    'Transfer matching data
    LR = dSh.Range("A" & Rows.Count).End(xlUp).Row
    dSh.Range("A2").AutoFilter
    dSh.Range("A2").AutoFilter Field:=1, Criteria1:="=*" & Val & "*"
    dSh.Range("B2:J" & LR).SpecialCells(xlCellTypeVisible).Copy Range("B9")
    dSh.Range("A2").AutoFilter




    Any help would be appreciated.

    Thanks,


    Stewart

  2. #2
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: search dates and text

    stewart1,

    This may help you get started in the right direction:

    Sub myCDType()
    ' Cell type(Data, Format, Formula test & Font), of single cell in MsgBox.

    By Joe Was
    http://www.mrexcel.com/forum/showthread.php?t=20611
    Have a great day,
    Stan

    Windows 10, Excel 2007, on a PC.

    If you are satisfied with the solution(s) provided, please mark your thread as Solved by clicking EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  3. #3
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: search dates and text

    Thanks for the reply Stan. I must tell you though that I am a complete novice with this. I have found this on code on an existing spreadsheet and I have amended it to search for the correct range. How do I merge the two together? I have a search box where I enter my query and a command button which retrieves the data from another sheet.

    Any further help would be great.

    Stewart

  4. #4
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: search dates and text

    stewart1,

    Please post your workbook. Click on the New Post button, then scroll down and click on the Manage Attachments button.

  5. #5
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: search dates and text

    Here you go. Hope you can help


    Stewart
    Attached Files Attached Files

  6. #6
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: search dates and text

    Hi Stan,

    If you are still about, did you have a chance to have a look at it.

    Thanks,


    Stewart

  7. #7
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: search dates and text

    stewart1,

    Detach/open workbook AdvancedFilter with Criteria and Extract and three CommandButtons - stewart1 - SDG13.xls.


    Click on worksheet SEARCH. And follow the instructions in range L12:L30.

  8. #8
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: search dates and text

    Hi Stan,

    That is much better, thank you! Is there anyway of just having one cell dedicated to searching all the data the same as in the search here tab. I dont want to dumb it down but it needs to be used by folks that are not really familiar with spreadsheets and if they were able to "enter, press and go" it would cut out possible problems. I owe you a pint so far!

    Thanks again,

    Stewart

  9. #9
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: search dates and text

    Can anyone else help? There has to be a way to search for both text and dates. Please see the "search-here tab" and you will see what I mean.

    Thanks


    Stewart

  10. #10
    Forum Expert
    Join Date
    10-10-2008
    Location
    Northeast Pennsylvania, USA
    MS-Off Ver
    Excel 2007
    Posts
    2,387

    Re: search dates and text

    stewart1,

    On worksheet SEARCH-HERE, for cell E2, how are entries made for dates?

    Can I see examples of dates to be entered.

  11. #11
    Registered User
    Join Date
    06-22-2010
    Location
    England
    MS-Off Ver
    Excel 2003
    Posts
    46

    Re: search dates and text

    Hi Stan,

    Sorry for a delayed reply,

    firstly, just letting you know that E3 and F3 are merged if that makes a difference.

    Anyway as my "DATABASE" is showing dates as 09/03/2010 I have been searching that way also.

    I have tried changing the whole date column in "DATABASE" so it can read read 09 march 2010 then going back to the "SEARCH-HERE"and typing just "march" but again I get nothing.

    (wish my boss had ACCESS, its already got a customer service template LOL!)

    I hope that made some sense.


    Thanks Stan,

    Stewart

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1