Results 1 to 3 of 3

Thread: Search for Numbers

  1. #1

    Search for Numbers


    Im looking for help to develop code to find numbers on my Excel sheet and then write the results. Ill be using it with other code so I can not use a formula.

    I have already posted this request but did not get the code I need at:
    I really have to have the search cells hard coded so I can add new ranges later on.


    - Project1 is the sheet code name.
    - The search range cells and the write cells are formatted as number.
    - I can only use hard code for the search range and write cell range. There will never be a change in cell location or sheet name.

    The code searches cell ranges E3:E14, H3:H14 (and other ranges to be added in the future) to locate numbers from 1 to 12 but a positive result would only occur if data is present in the adjacent cell to the right of any number 1to 12. A lot of cells with numbers 1 to 12 will have no data in them (in the adjacent cell to the right) so that would be a negative result. When this condition is met the code would then search cell range A3:A14, which has the number 1 in cell A3 all the way to 12 in cell A14 for the found number and write the found number in the adjacent cell to the right of it. There will always be found numbers. If the code finds two of the same numbers could it write err or something similar in the cell range B3:B14.

    Examples and expected results

    The first found number would be 3 in cell E5 and would be a positive result because there is data in cell F5. Using the found number 3, the code would then search the range A3:A14 for the number 3, cell A5, and then write 3 in the cell to the right of it B5. The second example is cell E9 with a 7 in it and has data in cell F9 so the code would write 7 in cell B9. Same for the third example in cell H11.

    Thanks for all your help.

    fins numbers.jpg
    Attached Files Attached Files

  2. #2
    Please close this posting.

  3. #3
    VBAX Wizard
    Apr 2007
    You can go to [Thread Tools] above your first post, and select [Solved]

    1. Use [CODE] ....[/CODE ] Tags for readability
    [CODE]PasteYourCodeHere[/CODE ] -- (or paste your code, select it, click [#] button)
    2. Upload an example
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s)
    (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    3. Mark the thread as [Solved] when you have an answer
    Thread Tools (on the top right corner, above the first message)
    4. Read the Forum FAQ, especially the part about cross-posting in other forums

Tags for this Thread

Posting Permissions

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