+ Reply to Thread
Results 1 to 7 of 7

Find command for multiple occurances and display

  1. #1
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Find command for multiple occurances and display

    Hello again

    I am looking to see if its possible in vba to use FIND code to locate multiple occurances in a sheet, and display all of them in a message box on the screen.

    I have come across several where they display the results in another worksheet, but looking for a msgbox display. I am wondering if I would use an array to house the address of each occurance I find and then show them all.

    thanks in advance.

  2. #2
    Valued Forum Contributor Gatti's Avatar
    Join Date
    06-08-2015
    Location
    Brasil, São Paulo, Ribeirão Preto
    MS-Off Ver
    365
    Posts
    346

    Re: Find command for multiple occurances and display

    What "occurance" you need to display?

    Please Login or Register  to view this content.
    This way I'm displaying EVERY cell that has values on UsedRange at sheet.

    If you need more specific occurance, tell me
    If I have solved your question, please mark the thread as [SOLVED],
    And consider adding reputation

    ?Simplicity is the ultimate sophistication? (Leonardo Da Vinci)

    Regards,
    F?bio Gatti

    https://www.youtube.com/pulodogatti
    https://www.linkedin.com/in/fabiocgatti/
    https://instagram.com/pulodogatti

  3. #3
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Find command for multiple occurances and display

    Thanks. Here is the code I already have written, and it will show just one occurance. There may be up to 30 or more occurances

    Please Login or Register  to view this content.
    So, I am looking to integrate your code into my code, but I am not quite sure how to marry them.

    Thanks

  4. #4
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Find command for multiple occurances and display

    Gatti

    Thanks for the assistance. I have been working on this and I think I am close. I was able to intergrate the 2 codes almost. Right now, I get a message box full of blank lines (representing all cells that are not blank). I am onyt attempting to return the location of the part numbers that are found. I was attempting to attach my whole project so you could see it, but I am unable (I think) to attach any file on these replies. Here is the code I am up to:

    [CODE][/
    Private Sub cmdFind_Click()



    Application.ScreenUpdating = False

    Dim PrtNo As String
    Dim srchRslt As Range
    Dim strMsgBox As String
    Dim Locate As Range

    strMsgBox = ""

    PrtNo = InputBox("What part number are you looking for?")

    Set srchRslt = Worksheets("Overview").Range("a1:zz10000").Find(What:=PrtNo, LookIn:=xlValues, LookAt:=xlWhole, _
    SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:=False)

    Set srchRslt = srchRslt.Offset(0, -2)

    While srchRslt <> "WITKO Rcvd Date"
    Set srchRslt = srchRslt.Offset(-1, 0)
    Wend

    Set Locate = srchRslt.Offset(-1, 0)

    For Each Locate In ActiveSheet.UsedRange

    If (Locate.Interior.ColorIndex = 37 Or 48) Then strMsgBox = strMsgBox & vbCrLf & Locate
    Next Locate



    MsgBox strMsgBox

    End Sub

    CODE]

    I was going to try and use the cell hilighted color for its location, but that isnt working the way I had anticipated.

    Thanks for all your assistance.

    Scott

  5. #5
    Registered User
    Join Date
    05-19-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Re: Find command for multiple occurances and display

    hello

    what is "WITKO Rcvd Date" ?name of colomne or values ?
    if is colomn do you want to step on it ?

    for the loction you can simply use :

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    07-08-2015
    Location
    Indiana
    MS-Off Ver
    Excel 2007
    Posts
    128

    Re: Find command for multiple occurances and display

    Quote Originally Posted by LOKLUK View Post
    hello

    what is "WITKO Rcvd Date" ?name of colomne or values ?

    Its the name of the column.


    Example of one


    N101C1 ********* Location - For example this one is in cell A2 (merged cell A2->D2)
    WITKO Rcvd Date Description Part # Pallet Tag ********* These are column headers. The table is 20 rows, and "WITKO Rcvd Date" is in cell A3

    00151 ************ This is one occurnence of the search for part number. Its in cell C7




















    if is colomn do you want to step on it ?

    for the loction you can simply use :

    Please Login or Register  to view this content.
    or
    Please Login or Register  to view this content.

    So, code finds the part number searched for (in this case, C7). Steps back using offset to cell A7, and works back up to locate the cell with "WITKO Rcvd Date". Once there, the "Location" is found with an offset up 1 row. In this case, Location = N101C1.

    What i am hoping to retun in a message box is the Location, N101C1.

    I can get one occurance of it.My probelm is now the part number searched for may be in up to 30 (or more) "Locations". And I need to show where they all are to the user.

    Does that help?

  7. #7
    Registered User
    Join Date
    05-19-2016
    Location
    London
    MS-Off Ver
    2007
    Posts
    26

    Re: Find command for multiple occurances and display

    hello
    NO, Please give us a sample of your project as workbook attachment, small workbook ,table with anonymizes values
    And please riposte Your question (a new post) to be sure that author members will participate

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] when command button in userform is pressed.. look to find multiple entries
    By Jenkins27 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-01-2015, 03:15 AM
  2. [SOLVED] Formula to find occurances
    By cmb80 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 04-04-2014, 05:01 AM
  3. [SOLVED] VBA Find, populate textbox, click command, findnext, display
    By ozhally in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2012, 09:39 PM
  4. Replies: 5
    Last Post: 05-11-2012, 03:38 AM
  5. find the 3 most recent occurances
    By cmb80 in forum Excel General
    Replies: 7
    Last Post: 01-26-2012, 05:06 PM
  6. Loop through all occurances of Find()
    By ChrisNor in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-17-2009, 11:13 AM
  7. [SOLVED] find multiple occurances of a value and match to values in another
    By carl43m in forum Excel General
    Replies: 1
    Last Post: 08-16-2006, 06:10 PM

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