![]() |
Search and replace tabulators of different length...?
2 Attachment(s)
Hi
I have this source text (*.rtf) containing information in (sort of) tab-seperated columns. I want to copy it into a excel worksheet to do further analyzing. My problem is, that the tabulator signs 'moving' the text into columns are of different length in the .rtf/.doc file, but exporting it excel treats them the same: In the rtf file the signs look like this: -------------> ------------------------------------------> Reading them as separators excel treats them alike. I guess what I'm looking for is an easy way to (maybe w/search&replace) make the 'long' tabs into several tabs: -------------> ------------->------------->-------------> Real examples attached It must be a 'automatic' solution, since we're talking about a rtf file of 1000+ pages.. |
You document has been formatted with different numbers of tab-stops for the different paragraphs, depending on what they contain. You can reformat the document with consistent tabbing with the following macro:
Code:
Sub Demo() |
1 Attachment(s)
Thank you sooooo much!!! This works (almost) exactly how I imagined. The only problem is:
When there is nothing in the last "column" in the source text, the macro moves the content from the second to last "column" to this one instead, or, moves everything a column too much to the right (maybe that what it does). New example (1th page source text, 2nd page after macro) |
Try the following code revision:
Code:
Sub Demo() |
First of all thank you so much!!
Is it possible to add some code to the macro, making it possible to follow the progress - without delaying it too much? What I mean is, since the document is VERY long, literally thousands of pages, the process always takes a while (not to sat a very long time). It would be nice to be able to follow the process. Not by adding Code:
Application.ScreenUpdating = True |
Try:
Code:
Sub Demo() |
Hi again
You're a genius.... Thanks. Is there any tweaks one could add to make it run faster? I see now, that there is 275103 paragraphs and it takes appr. 1500 pr. 10 min now? |
I've tweaked the code for about as much performance as can be eked out of it:
Code:
Sub Demo() Ultimately, you'd do far better getting whatever's generating the source file to put all the required tabs into the file at the outset. |
Wow, thanks... Already much faster
Which part do I change to a) make the updating less frequent ( is it i = i + 1 -> i = i +, say, 10 or 25?? b) remove the progress report completely |
To delete the progress report, comment out or delete the line:
Application.StatusBar = "Processing paragraph " & i & " of " & l To give, say, a % progress report requires adding more code to calculate the %. That calculation has its own overhead which, compared, updating the screen as per the existing progress report, takes only marginally less time. An alternative would be to relocate the existing status code to just above/below the 'DoEvents' line. That'll update the report only every 10th paragraph. |
All times are GMT -7. The time now is 06:43 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by
DragonByte SEO (Lite) -
vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft