Wild card search for word and copy the number following the searched word into new column

mkseto

New Member
Joined
Aug 14, 2018
Messages
38
Looking for a VBA solution to do the following:
*** user has a number (200-300) TXT files stored in a folder, each TXT file has multiple pages with details of client records for a particular retail store, and the store number appears on the first line of each page in the format of "Store# : #####". There are blank lines after each records, therefore many blank lines in each page. See sample #1 below.

1) Prompt user to select a folder, then import all TXT files found and merge into one sheet called "MergedSheet".
2) Delete all blank rows
3) Insert a new column (left-most) and perform a wild card search to look for the word "Store" in each row and, if found, copy of the number found after the text "Store# :" and place in the new column "A" of that respective row.
4) Perform TEXT-TO-COLUMN to column "B" (i.e. originally column "A" before steps #2)

For #2, I could find a lot of answers to delete blank rows but for some strange reasons, none of them worked for me (after running the macro, all the blank rows are still there despite no error from the macro). However, if I do a "text to column" first to divide up the rows, all the macros worked.
For #3, I can do a wild card search but don't know how to retrieve the number after the search word to place in column A.
For #4, I should be able to figure this out myself but would appreciate if this can be included in the solution as well

Appreciate help!

Sample TXT file layout (note that some records have one line while some others have multiple lines. Each record always starts with a "REF#" on the first line)
TXT File.gif



Sample Excel file after import/merge:
After merge.gif
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.

Forum statistics

Threads
1,223,911
Messages
6,175,324
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top