+ Reply to Thread
Results 1 to 2 of 2

Search macro

  1. #1
    Registered User
    Join Date
    12-22-2010
    Location
    Slovakia
    MS-Off Ver
    Excel 2010
    Posts
    20

    Search macro

    Hi,

    im trying to adjust search macro for excel. For successfull run i need to type exact value to search box. I need a macro which will be able to search not only the exact values bot part of them as well. For example.. if i want to search for number "2", i dont need to put search value 2.00. but only 2. Right now if i dont put 2.00, it wont find anything.
    Here is the macro..:

    Sub Search()

    Dim datatoFind
    Dim sheetCount As Integer
    Dim counter As Integer
    Dim currentSheet As Integer

    On Error Resume Next
    currentSheet = ActiveSheet.Index
    datatoFind = InputBox("Please enter the value to search for")
    If datatoFind = "" Then Exit Sub
    sheetCount = ActiveWorkbook.Sheets.Count
    If IsError(CDbl(datatoFind)) = False Then datatoFind = CDbl(datatoFind)
    For counter = 1 To sheetCount
    Sheets(counter).Activate
    Cells.Find(What:=datatoFind, After:=ActiveCell, LookIn:=xlFormulas, LookAt _
    :=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
    False).Activate
    If ActiveCell.Value = datatoFind Then Exit Sub
    Next counter
    If ActiveCell.Value <> datatoFind Then
    MsgBox ("Value not found")
    Sheets(currentSheet).Activate
    End If
    End Sub

  2. #2
    Registered User
    Join Date
    12-22-2010
    Location
    Slovakia
    MS-Off Ver
    Excel 2010
    Posts
    20

    Re: Search macro

    I can imagine, it could be something simple.. change the search option, but since i wasnt blessed with VBA understanding, i cant fix it myself. Please help me out here..

    IB

+ 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