• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA Macro Beginner Help Request

lim87c

New Member
Hello,

I have a text file which has large strings of information inside, however I am only looking to extract small pieces of info out. The numbers that should be extracted is color coded and should output into 4 columns.

Column 1 (Max HC, usually 2 digits): ##
Column 2 (Actual HC, usually 1 digit): #
Column 3 (Units Requested, variable number of digits): #.###
Column 4 (Units Delivered, variable number of digits): #.####

What's the quickest way to go about doing this?

Source data is in a text file, but can be put into excel if its easier for the macro:

Row 1: Bionic> 118390: DEBUG unit_deliver(): <Unit> Expected Max HC=12
Row 2: 119157: INFO unit_deliver(): <Unit> started delivery of 0.002 Units (0.020 uL) (timeout_ms 9688 msec)
Row 3: 121157: INFO unit_deliver(): <unit> total delivery amount=0.0190 uL, hc=6

This text string (3 rows) repeats for about 800 times.

Thanks in advance!
 
Using your file:
D3: =IF(IFERROR(SEARCH("Max HC",B3),0)>0,RIGHT(B3,2),"")
E3: =IF(IFERROR(FIND("hc",B3),0)>0,RIGHT(B3,1),"")
F3: =IF(IFERROR(FIND("delivery of",B3),0)>0,MID(B3,SEARCH("delivery of",B3)+12,5),"")
G3: =IF(IFERROR(FIND("amount=",B3),0)>0,MID(B3,SEARCH("amount=",B3)+7,6),"")

copy all down
 
Thanks!

What if I wanted to achieve the same result using VBA? I will have larger text files in the future with more difficult parameters, and wanted to get a jump start on learning how to extract that information.
 
As it depends on source file and on expected file as well,
see post #4 like forum rules …

Or you can activate the Macro Recorder and operate manually
to create the formula and copy it down following Hui's way :
you will get your own code base, a good start to learn !

Or read the VBA help for Open statement as a good start too …

Many samples on forums …
 
Back
Top