Insert row based on criteria

Jsin

New Member
Joined
Nov 30, 2010
Messages
18
Ultimate goal: Insert a page break at each blank row. I have the macro to insert page breaks already.

I run a report several times a day that needs to be printed and handed out to different people for specific tasks to be taken care of. The issue is that I get the data in one lump and I have to manually insert page breaks each time. There are a large number of 'Locations' that are grouped together to be handed to different people. The bulk of this can be separated just by the first letter of each location. Below is an example of what my data looks like, it only needs to insert a row based on what's in column A.

Code:
                                                                                                                                                                                                                                                                                                                                                                           <table x:str="" style="border-collapse: collapse; width: 166pt;" border="0" cellpadding="0" cellspacing="0" width="222"><col style="width: 48pt;" width="64"> <col style="width: 59pt;" span="2" width="79"> <tbody><tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt; width: 48pt;" height="17" width="64">
</td> <td style="width: 59pt;" width="79">Original data</td> <td style="width: 59pt;" width="79">
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">
</td> <td>
</td> <td>
</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-A-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-A-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-A-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-B-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-B-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-B-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-C-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-C-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">A-C-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-A-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-A-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-A-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-B-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-B-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-B-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-C-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-C-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-C-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-D-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-D-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-D-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-E-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-E-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-E-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-F-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-F-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">B-F-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-A-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-A-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-A-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-B-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-B-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-B-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-C-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-C-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-C-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-D-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-D-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-D-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-E-0</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-E-1</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-E-2</td> <td>random data</td> <td>random data</td> </tr> <tr style="height: 12.75pt;" height="17"> <td style="height: 12.75pt;" height="17">C-F-0</td> <td>random data</td> <td>random data</td> </tr> </tbody></table>

Code:
  <table x:str="" style="border-collapse: collapse; width: 191pt;" border="0" cellpadding="0" cellspacing="0" width="255"><col style="width: 48pt;" width="64">  <col style="width: 84pt;" width="112">  <col style="width: 59pt;" width="79">  <tbody><tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt; width: 48pt;" height="17" width="64">
</td>   <td style="width: 84pt;" width="112">Needs to look like</td>   <td style="width: 59pt;" width="79">
</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">
</td>   <td>
</td>   <td>
</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-A-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-A-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-A-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-B-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-B-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-B-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-C-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-C-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">A-C-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">
</td>   <td>
</td>   <td>
</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-A-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-A-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-A-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-B-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-B-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-B-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-C-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-C-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-C-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-D-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-D-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-D-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-E-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-E-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-E-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-F-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-F-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">B-F-2</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">
</td>   <td>
</td>   <td>
</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">C-A-0</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">C-A-1</td>   <td>random data</td>   <td>random data</td>  </tr>  <tr style="height: 12.75pt;" height="17">   <td style="height: 12.75pt;" height="17">C-A-2</td>   <td>random data</td>   <td>random data</td>  </tr> </tbody></table>
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
Ultimate goal: Insert a page break at each blank row. I have the macro to insert page breaks already.

I run a report several times a day that needs to be printed and handed out to different people for specific tasks to be taken care of. The issue is that I get the data in one lump and I have to manually insert page breaks each time. There are a large number of 'Locations' that are grouped together to be handed to different people. The bulk of this can be separated just by the first letter of each location. Below is an example of what my data looks like, it only needs to insert a row based on what's in column A.

Code:
<TABLE style="WIDTH: 166pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=222 x:str=""><COLGROUP><COL style="WIDTH: 48pt" width=64><COL style="WIDTH: 59pt" span=2 width=79><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD style="WIDTH: 48pt; HEIGHT: 12.75pt" height=17 width=64>

</TD><TD style="WIDTH: 59pt" width=79>Original data</TD><TD style="WIDTH: 59pt" width=79>

</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>

</TD><TD>

</TD><TD>

</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-A-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-A-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-A-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-B-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-B-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-B-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-C-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-C-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>A-C-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-A-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-A-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-A-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-B-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-B-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-B-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-C-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-C-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-C-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-D-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-D-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-D-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-E-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-E-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-E-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-F-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-F-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>B-F-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-A-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-A-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-A-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-B-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-B-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-B-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-C-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-C-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-C-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-D-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-D-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-D-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-E-0</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-E-1</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-E-2</TD><TD>random data</TD><TD>random data</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD style="HEIGHT: 12.75pt" height=17>C-F-0</TD><TD>random data</TD><TD>random data</TD></TR></TBODY></TABLE>

Code:
  <TABLE style="WIDTH: 191pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=255 x:str=""><COLGROUP><COL style="WIDTH: 48pt" width=64> <COLGROUP><COL style="WIDTH: 84pt" width=112> <COLGROUP><COL style="WIDTH: 59pt" width=79> <TBODY><TR style="HEIGHT: 12.75pt" height=17>  <TD style="WIDTH: 48pt; HEIGHT: 12.75pt" height=17 width=64>

</TD>  <TD style="WIDTH: 84pt" width=112>Needs to look like</TD>  <TD style="WIDTH: 59pt" width=79>

</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>

</TD>  <TD>

</TD>  <TD>

</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-A-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-A-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-A-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-B-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-B-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-B-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-C-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-C-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>A-C-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>

</TD>  <TD>

</TD>  <TD>

</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-A-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-A-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-A-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-B-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-B-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-B-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-C-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-C-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-C-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-D-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-D-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-D-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-E-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-E-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-E-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-F-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-F-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>B-F-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>

</TD>  <TD>

</TD>  <TD>

</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>C-A-0</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>C-A-1</TD>  <TD>random data</TD>  <TD>random data</TD> </TR> <TR style="HEIGHT: 12.75pt" height=17>  <TD style="HEIGHT: 12.75pt" height=17>C-A-2</TD>  <TD>random data</TD>  <TD>random data</TD> </TR></TBODY></TABLE>
Hi,
as your ultimate goal is to insert breaks, try
Code:
Sub insertBreak()
    
    lag = Mid(Worksheets("Sheet1").Cells(4, 1).Value, 1, 1) 'remeber last cell
    i = 5 'counter
    Do While Cells(i, 1) <> "" 'do while not empty
        mynew = Mid(Cells(i, 1), 1, 1) 'current cell
        If mynew <> lag Then 'if they are different
            Cells(i, 1).Activate 'goto changed cell
            ActiveWindow.SelectedSheets.HPageBreaks.Add Before:=ActiveCell 'insert break
            lag = mynew 'update remembered info
        End If
        i = i + 1 'move on to next cell
    Loop
End Sub

if you still want to insert blank rows, you can add code for that around the HPageBreaks line
HTH
 
Upvote 0
Thanks, it appears to work as needed! I'll run it a few times today and ensure that it does.

- Jason
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,331
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top