The reason that when you run 'Process_Data' it is because of the way you are detecting which lines to delete.
Take the first 'customer' in the example you have uploaded:
"TOWSWWSWSYWSWSWSW"
When you are looking for lines to delete you have defined your search patterns thus:
If we look at this carefully...
"TOWSWWSWSYWSWSWSW"
So you can see from above that the cell with the customer name in matches the search pattern, and so that line will be deleted, losing 1 line of customer data.
Although this is a 'mock up' so that you could upload an example I would guess that maybe you have a customer name that matches one of the search patterns.
The easy way to find out is to select the "IN1" tab, and then run the "Delete_Report_Header_And_Blanks()" Macro. You will then need to scroll down through the data to see if anything doesn't seem to follow the expected pattern.
As I said before I would advise you get rid of the "*" in the search string as they are not needed, (I may have inadvertantly copy & pasted them from one of your examples!). You can then look closer at your patterns.
Sticking with the same example for instance I presume the "To" line that you are trying to remove is similar to the one on row 3 of your example:
"01/04/2008 To"
but you dont want to delete:
"TOWSWWSWSYWSWSWSW"
To overcome this you could modifier your search pattern to look for " To" (note the prefixed space).
When you want to match data, whether you are trying to INCLUDE, or EXCLUDE it, it is always a good idea to include as much of the fixed data as possible to try and avoid incorrect matches.
I have looked at your raw data and I believe changing your search pattern to this will serve you well:
NOTE There are 2 different types of --- on your raw data, one of which the forum can not display. For that reason I have modified the search pattern in the attached workbook, do NOT just copy and paste it from above.
It also seems that your raw data contains one cell in the 1st column that contains just " ", (a single space). Due to this although the cell LOOKS blank, it does not get deleted by the routine that deletes the blank rows.
To cope with this I have now thrown in an EXTRA "Find" case purely to look for rows where that first cell contains a single space, and then delete the row. Also note that when search for the spaces the find function is using "LookAt:=xlWhole" so that it only matches if the entire cell contents matches " ". This stops it matching a cell that contains a space, but also other text, such as "My Company".
The complete code for the 'Delete_Report_Header_And_Blanks()' function now looks like this, but remember use the one in the attached workbook, not copy and paste due to the problems with the dashes
Hopefully that should either fix it or get you a lot closer
Bookmarks