Complex Filtering process

2011everafter

Board Regular
Joined
Oct 5, 2011
Messages
129
Dear Helpers,

Another complex scenario , I need to filter the below data base based on the 1ST time , provided the Trip Sequence follows the 1ST time.

Data Base:-

<TABLE style="WIDTH: 330pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=440><COLGROUP><COL style="WIDTH: 42pt; mso-width-source: userset; mso-width-alt: 2048" width=56><COL style="WIDTH: 48pt" span=6 width=64><TBODY><TR style="HEIGHT: 26.25pt" height=35><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #c5d9f1; WIDTH: 42pt; HEIGHT: 26.25pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 height=35 width=56>TRIP#

</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>1ST TIME </TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>Trip Code</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>Count</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>1st Stn</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>2nd Stn</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>Trip Sequence</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 height=21 width=56>XXX0741</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>1230</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>$AA32</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>70</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>CDG</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>FRA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>3270001</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #b8cce4; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 height=21 width=56>XXX1108</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>800</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>$BBK</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>142</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>LHR</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>3270002</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #b8cce4; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 height=21 width=56>XXX0740</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>1225</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>$CC32</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>124</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>GVA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>3270002</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #efefef; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 height=21 width=56>XXX0144</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>1150</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>$DDA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>98</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>CDG</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>DUB</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #efefef; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>3270003</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #e6b8b7; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 height=21 width=56>XXX1032</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=64 align=right>1030</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=64>$MM19</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=64 align=right>47</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=64>BRU</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 width=64 align=right>3270004</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #ccc0da; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 height=21 width=56>XXX0510</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 width=64 align=right>1410</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 width=64>$VV19</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 width=64 align=right>132</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 width=64>GVA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 width=64 align=right>5270004</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #fabf8f; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 height=21 width=56>XXX0511</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 width=64 align=right>1835</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 width=64>$VV19</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 width=64 align=right>84</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 width=64>GVA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 width=64>CDG</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64 align=right>6270004</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: yellow; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 height=21 width=56>XXX1145</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>1230</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>$KK31</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>133</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>FCO</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>ATH</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>3270005</TD></TR><TR style="HEIGHT: 15pt" height=20><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: yellow; WIDTH: 42pt; HEIGHT: 15pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 height=20 width=56>XXX1047</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64 align=right>1700</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64>$KK31</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64 align=right>132</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64>ATH</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64>CDG</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64 align=right>3270005

</TD></TR></TBODY></TABLE>


When I do the filtering by the 1ST time , I want also all the matching Trip Sequence follow the 1St time.

I want the filter to show :-

<TABLE style="WIDTH: 330pt; BORDER-COLLAPSE: collapse" border=0 cellSpacing=0 cellPadding=0 width=440><COLGROUP><COL style="WIDTH: 42pt; mso-width-source: userset; mso-width-alt: 2048" width=56><COL style="WIDTH: 48pt" span=6 width=64><TBODY><TR style="HEIGHT: 26.25pt" height=35><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #c5d9f1; WIDTH: 42pt; HEIGHT: 26.25pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" id=td_post_2920692 class=xl65 height=35 width=56>TRIP#

</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>1ST TIME </TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>Trip Code</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>Count</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>1st Stn</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>2nd Stn</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c5d9f1; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl65 width=64>Trip Sequence</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #b8cce4; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 height=21 width=56>XXX1108</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>800</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>$BBK</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>142</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>LHR</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>3270002</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #b8cce4; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 height=21 width=56>XXX0740</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>1225</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>$CC32</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>124</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64>GVA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #b8cce4; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl67 width=64 align=right>3270002</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #e6b8b7; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 height=21 width=56>XXX1032</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>1030</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>$MM19</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64 align=right>47</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>BRU</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl68 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #e6b8b7; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl69 width=64 align=right>3270004</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #92d050; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 height=21 width=56>XXX0144</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #92d050; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64 align=right>1150</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #92d050; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64>$DDA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #92d050; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64 align=right>98</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #92d050; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64>CDG</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #92d050; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64>DUB</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #92d050; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl75 width=64 align=right>3270003</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #c0504d; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 height=21 width=56>XXX0741</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c0504d; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 width=64 align=right>1230</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c0504d; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 width=64>$AA32</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c0504d; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 width=64 align=right>70</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c0504d; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 width=64>CDG</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c0504d; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 width=64>FRA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #c0504d; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl76 width=64 align=right>3270001</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: yellow; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 height=21 width=56>XXX1145</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>1230</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>$KK31</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>133</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>FCO</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64>ATH</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl66 width=64 align=right>3270005</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: yellow; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 height=21 width=56>XXX1047</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64 align=right>1700</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64>$KK31</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64 align=right>132</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64>ATH</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64>CDG</TD><TD style="BORDER-BOTTOM: #f0f0f0; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: yellow; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl74 width=64 align=right>3270005</TD></TR>

<TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #ccc0da; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 height=21 width=56>XXX0510</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 width=64 align=right>1410</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 width=64>$VV19</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 width=64 align=right>132</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 width=64>AMS</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl70 width=64>GVA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #ccc0da; WIDTH: 48pt; BORDER-TOP: #3867a6 1pt solid; BORDER-RIGHT: #3867a6 1pt solid" class=xl71 width=64 align=right>5270004</TD></TR><TR style="HEIGHT: 15.75pt" height=21><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6 1pt solid; BACKGROUND-COLOR: #fabf8f; WIDTH: 42pt; HEIGHT: 15.75pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 height=21 width=56>XXX0511</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 width=64 align=right>1835</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 width=64>$VV19</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 width=64 align=right>84</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 width=64>GVA</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl72 width=64>CDG</TD><TD style="BORDER-BOTTOM: #3867a6 1pt solid; BORDER-LEFT: #3867a6; BACKGROUND-COLOR: #fabf8f; WIDTH: 48pt; BORDER-TOP: #3867a6; BORDER-RIGHT: #3867a6 1pt solid" class=xl73 width=64 align=right>6270004</TD></TR></TBODY></TABLE>


Thank you.
 
Last edited:
I did insert the protection code as shown below but I am getting error in the Complex_Filtering module

Compile error:
Variable not defined


I inserted the protection code at the beginning of the complex_Filtering module as shown below

Sub Complex_Filtering()
ActiveSheet.Unprotect Password = "xyz12345"
Dim lngLastRow As Long, lngRow As Long, lngNextTrip As Long
Dim wks As Worksheet

Then at the end of the module I inserted it as shown below

With Application
.ScreenUpdating = True
.Calculation = xlCalculationAutomatic
ActiveSheet.Protect Password = "xyz12345"
End With
End Sub

I dont know if I am inserting those protection codes on the correct lines?

Thank you.
 
Upvote 0

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Not tested but this should work:

Code:
Option Explicit
Public Enum RowOrColumn
    Row = 1
    Column = 2
End Enum

Sub Complex_Filtering()
    Dim lngLastRow As Long, lngRow As Long, lngNextTrip As Long
    Dim wks As Worksheet
   
    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With
    
    Set wks = ActiveSheet
   
    With wks
         lngLastRow = .Cells(.Rows.Count, "J").End(xlUp).Row

         .Unprotect Password = "xyz12345"

        .Sort.SortFields.Clear
        .Sort.SortFields.Add Key:=Range("B2:B" & lngLastRow), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
            With .Sort
                .SetRange Range("A1:J" & lngLastRow)
                .Header = xlYes
                .MatchCase = False
                .Orientation = xlTopToBottom
                .SortMethod = xlPinYin
                .Apply
            End With
            
      For lngRow = 2 To lngLastRow - 1
        lngNextTrip = Find_Data(.Range("J" & lngRow).Value, .Range("J" & lngRow + 1 & ":J" & lngLastRow), 1, xlWhole)
            If lngNextTrip > 0 Then
                Range("A" & lngNextTrip & ":J" & lngNextTrip).Cut
                Range("A" & lngRow + 1 & ":J" & lngRow + 1).Insert Shift:=xlDown
            End If
      Next lngRow

      .Protect Password = "xyz12345"

    End With

    With Application
        .ScreenUpdating = True
        .Calculation = xlCalculationAutomatic
    End With

End Sub

Function Find_Data(what As String, rng As Range, how As RowOrColumn, Optional LookAt As XlLookAt = xlPart)

Select Case how
        
    Case 1:
        On Error Resume Next
        Find_Data = rng.Find(what:=what, _
                        After:=rng.Cells(1), _
                        LookAt:=LookAt, _
                        LookIn:=xlFormulas, _
                        SearchOrder:=xlByRows, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False).Row
        On Error GoTo 0

    Case 2:
        On Error Resume Next
        Find_Data = rng.Find(what:=what, _
                        After:=rng.Cells(1), _
                        LookAt:=LookAt, _
                        LookIn:=xlFormulas, _
                        SearchOrder:=xlByColumns, _
                        SearchDirection:=xlNext, _
                        MatchCase:=False).Column
        On Error GoTo 0
End Select

End Function
 
Last edited:
Upvote 0
I am sorry, but I am still getting the complie error , variable not defined.

with yellow highlight on the

Sub Complex_Filtering()

and a dark shade on the word "password"

.Unprotect Password = "xyz12345"


btw the workbook is protected by the same password , meaning , no one can open the workbook without entering a password, but the sheet itself is only protected by the other MACRO I am running on it.

Oh , and I forgot to mention that , I am also protecting the VB code using a password, meaning , no one can edit any VB modules without first entering a password , again , I am using the same password to be able to enter the VB mode.

Thank you again.
 
Last edited:
Upvote 0
I will test it for all the Scenarios I have on the Sheet and let you know,

I noticed when I removed the passwords from the other MACRO , the password in the Complex_Filtering actually protected the sheet.

I guess you cant have 2 MACROs with 2 passwords?

Thank you.
 
Upvote 0
well they'd have to be the same passwords, but it shouldn't be a problem. Just need to make sure that both unlock @ the start of the macro and both lock @ the end of the macro.
 
Upvote 0
Hello again,

I did some test on the Complex_filtering and here is what I noticed:-

I have 10 MACROs in the sheet " PRIMERY" , each of these MACROs copy data from another sheet in the same Workbook and past it in the PRIMERY, then for each data copied I run the Complex_filtering MACRO.

Here is what I noticed when I copied each data using MACROS and for each data I runned Complex_filtering MACRO.

1) MACRO1 copied 540 records and when I run the Complex_filtering MACRO it gave me an error Run-time error 1004 and the cursor stopped at row 112 of the data.

2) MACRO2 copied 214 records no error running the Complex filtering.

3) MACRO3 copied 101 records gave no error and the complex filtering MACRO runned fine.

4) MACRO4 copied 114 records same error as 1 above and stopped at row 58.

5) MACRO5 copied 27 records same error as 1 above and stopped at row 20.

6) MACRO6 copied 18 records same error as 1 above and stopped at row 14.

7) MACRO7 copied 69 records no error running the Complex filtering.

8) MACRO8 copied 94 records same error as 1 above and stopped at row 44.

9) MACRO9 copied 8 records no error running the Complex filtering.

10) MACRO10 copied 1 record no error running the Complex filtering.

All the errors were referring to Run-time 1004 error and the error says " this selection is invalid , there are several possible reasons " , the debug highlights in yellow this line of the code :-

Range("A" & lngRow + 1 & ":J" & lngRow + 1).Insert Shift:=xlDown


Thanks.
 
Upvote 0
Are any of the cells merged? That's a lot of macros and not a lot of information to go on. Since the "complex macro works after some of your macros and not after others, I'm guessing it's because of either the format of the information being carried over or some formatting applied during those macro runs. First thing I would check for is if any of the rows are merged after your macros run...
 
Upvote 0

Forum statistics

Threads
1,216,016
Messages
6,128,299
Members
449,437
Latest member
Raj9505

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