Hownow wrote:What does the search & replace for the same string accomplish?
It does nothing or exactly in your case without Find option MatchCase it converts the word trade in any case to "Trade". It's just for testing if a specific string is within the current line. It simply restricts the find on a single line.
I guess your loop is not working because there is missing the command EndLoop. And in the IfNotFound branch you have forgottenEndSelect
Key UP ARROW
before Key END. SelectLine selects the whole line including the line terminator and the cursor is at start of the next line.
If you are a macro beginner you should test your macro step by step by inserting the macro command ExitMacro after every important command sequence and look what happens when executing the macro to this point. Then reload the file to restore all changes, edit the macro and move the ExitMacro command down, run the macro again, look again, reload the file, ...
But I think for your problem there is a much faster solution.
Find Select "Trade"
Key UP ARROW
Replace All SelectText " "
What this macro does?
From top of the file it selects everything till word "Trade". If the word "Trade" (or "trade" or "tRaDe" or ...) is found and so a selection exists, it removes from the selection the current line by setting the cursor to the end of the previous line (or current line if "Trade" is found at first line of the file). Because of the StartSelect command all cursor moves modify the selection until EndSelect is used. Then it replaces in the whole selected text all CRLF by a space to concatenate the lines. If your file is a Unix file opened in Unix mode you have to use ^n instead of ^p.
I'm not sure if the line with "Trade" should be also added to the concatenate block or not. The macro above will not add it. Remove the macro commandsKey UP ARROW
and the text of the line with "Trade" is at the end of the single line after the macro execution.