+ Reply to Thread
Results 1 to 8 of 8

VBA to find text in specific format in a workbook

  1. #1
    Registered User
    Join Date
    06-05-2013
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2010
    Posts
    12

    VBA to find text in specific format in a workbook

    I am looking for code to find text in a specific format with in a workbook. The code would be

    Please Login or Register  to view this content.
    if I wanted to search every cell, but I am hoping there is a quicker way using worksheet.find(). ex:

    Please Login or Register  to view this content.
    Thanks for any help,
    H

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA to find text in specific format in a workbook

    There are several experts working on this already, so I won't join them as yet.

    I must say however you haven't stated what you want done when and if that data is found.

    May I suggest that an index sheet be created and a list created in columns A, B and C

    Column A to list the sheets in which the text appears
    Column B to list the cell in which the text appears
    Column C to list the exact contents of that cell.

  3. #3
    Registered User
    Join Date
    06-05-2013
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA to find text in specific format in a workbook

    The cells containing the text in that format are names of data entries over several years. I am looking for a quick way to cycle through several workbooks and collect the data associated with that name.
    The problem comes because the format of the workbooks is not consistent and the data associated with the name is located on one sheet in each workbook. The sheet name and number are not consistent
    from workbook to workbook. To make things more complicated there are other tables on the same worksheet that contain similar data, but not reduced to the name. Long story short, I will take the cell
    contents and the contents of the next 11 cells in that row and paste them in a table in the workbook running the macro. I believe I know how to write the rest of the code, but am struggling with finding
    the data in the workbook.

    Thank you for the look ahead and suggestion,
    H

  4. #4
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: VBA to find text in specific format in a workbook

    This will find cells formatted as currency.

    Please Login or Register  to view this content.
    Perhaps you can modify for your use. Hope that helps.

  5. #5
    Registered User
    Join Date
    06-05-2013
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA to find text in specific format in a workbook

    I have been unable to modify the code so far. It appears that the numberformat will only accept numbers and there is no text format I can find. Does anyone have an idea?

    Thanks for code,
    H

  6. #6
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: VBA to find text in specific format in a workbook

    Ok H

    I see you are stuck so I'll look at this for you.

    I need more information on this format:-

    "####-#[A,B,C]*"

    the # is probably a number

    What do these mean?
    A,
    B,
    C,

    What does * mean?

    I will write the bulk of the code for you and fine tune tomorrow.

    The plan is that you put my spreadsheet into the same folder as the workbooks you want analysed

    Opening the workbook will run the macro and the macro will search every workbook and every sheet

    A summary sheet will created where

    Column A to list the workbook in which the text appears
    Column A to list the sheets in which the text appears
    Column C to list the cell in which the text appears
    Column D to list the exact contents of that cell.
    Columns E to N will contain the data from the 11 cells following the target cell.

    Ok wish Me Luck

    Ok we have something to play with.

    There are two files attached.

    Searcher.xlsm is the macro

    Book1.xlsx is a sample

    put them into the same folder and open searcher.

    For now I have given you a button to push, tomorrow I will set it to run automatically.

    Look at the results page. All it has is a row of titles

    click on the button.

    view the results.

    create more versions of book1 with different names different numbers of sheets etc
    all in the same folder.

    click on the button.

    the code for the macro is:-

    Please Login or Register  to view this content.



    However the killer part is quite simple:-

    Please Login or Register  to view this content.

    Thats the bit that may need fine tuning.

    If the flag is true after that lot we save data

    But you can see how easy it is to refine our search.
    Attached Files Attached Files
    Last edited by mehmetcik; 12-12-2014 at 09:48 PM.

  7. #7
    Registered User
    Join Date
    06-05-2013
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA to find text in specific format in a workbook

    I greatly appreciate the help. If I use an If statement tied with Like the format is # is a number and letters put in a bracket are possible letters. For example:

    Please Login or Register  to view this content.
    would only return true if the cells contents had four numbers then a dash followed by a number and a letter. The star means that any value can exist in the rest of the string [Letters and numbers]. The reason is the names change for every instance and there are multiple areas inside each instance therefore only the fist part of the name convention is the same every time. That is 4 numbers followed by a dash then another number and a letter.

    Thank you again and I will be by my email if you have any questions,
    H

  8. #8
    Registered User
    Join Date
    06-05-2013
    Location
    Denver Colorado
    MS-Off Ver
    Excel 2010
    Posts
    12

    Re: VBA to find text in specific format in a workbook

    Thanks for all the hard work. The code looks good, but I don't have access to the excel workbooks until tomorrow. I will let you know how it goes.

    Thanks again,
    H

+ 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. Replies: 20
    Last Post: 01-11-2014, 05:39 AM
  2. Replies: 2
    Last Post: 08-05-2013, 07:32 PM
  3. [SOLVED] Macro to convert specific text and format specific text within a string
    By Mencae in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 12-06-2012, 12:13 AM
  4. Replies: 1
    Last Post: 07-19-2012, 02:27 PM
  5. fastest way to find the row where a specific text is found in a specific column
    By getgray in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 07-23-2011, 02:45 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