Originally Posted by
Leith Ross
Hello DJ,
You're welcome. The best thanks come when you have taught someone something new. When you can use that knowledge later on then I have done my job.
Leith
Thank you for your code, and coming to the rescue of the OP. I have a similar issue of parsing lines from a text file matching around 34 keywords in my file.
A specific textfile from my folder can be download from this link. https://uploadfiles.io/y9qur
I used the code you provided to the OP with the only modifications being the line on the worksheet where data is placed, the variant KEYS with my own keywords and I also commented out the line 'Intersect(Rng.CurrentRegion, Rng.CurrentRegion.Offset(1, 0)).ClearContents'
Here are the lines I modified :
Keys = Array("Mean RR (ms)", "STD RR (ms)", "Mean HR (beats/min)", "STD HR (beats/min)", "Min HR (beats/min)", "Max HR (beats/min)", "RMSSD (ms)", "NNxx (beats)", "pNNxx (%)", "RR tri index", "TINN (ms)", "VLF (Hz)", "LF (Hz)", "HF (Hz)", "VLF (ms^2)", "LF (ms^2)", "HF (ms^2)", "VLF (log)", "LF (log)", "HF (log)", "VLF (%)", "LF (%)", "HF (%)", "LF (n.u.)", "HF (n.u.)", "Total power (ms^2)", "LF/HF ratio", "SD1 (ms)", "SD2 (ms)", "SD2/SD1 ratio", "Approximate entropy (ApEn)", "Sample entropy (SampEn)", "alpha 1", "alpha 2")
Set Wks = ActiveSheet
Set Rng = Wks.Range("A2")
I assigned the macro to a button on my sheet of interest.
When I run this code, a couple of observations in the parsed output on the excel sheet :
1. Minor issue - Certain data lines are parsed more than once into the column. This is happening exactly for the text lines for "VLF (Hz):" , "VLF (ms^2):", "VLF (log):". I'm guessing with a small tweak this can be fixed.
2. Major issue - The parsing stops after the text line for "SD2/SD1 ratio:" is copied. The last 4 keywords in KEYS is not parsed and the operation moves onto the next file. This happens for all the files. My guess is that the variant KEYS has an array limit. Or is it the memory of my system?
Please help with a tweak because your code does 95% of what I'm looking for...
Cheers !