BRUCEWAYNE
New Member
- Joined
- May 15, 2019
- Messages
- 7
HI5 folks,
i wish to find triplets of numbers with the difference of 11 within each row/line in the excel spreedsheet. three any numbers (x,y,z) whose difference is 11 , in other words z-y=11 , y-x=11. I use excel 2007. I tried it by using this code below:
this code did the calculation only for some rows of input data posted bellow. It didn't do the calculation until the end of input data, it seems to stop in the middle of of input data and it's omiting some results . For example, it didn't show one the results (27,38,49) such as from the input data [TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl66, width: 64"]10[/TD]
[TD="class: xl66, width: 64"]27[/TD]
[TD="class: xl66, width: 64"]38[/TD]
[TD="class: xl66, width: 64"]40[/TD]
[TD="class: xl66, width: 64"]49[/TD]
[TD="class: xl66, width: 64"]55[/TD]
[/TR]
</tbody>[/TABLE]
i used as general input data the list bellow:
Can someone help me?
Many Thanks
i wish to find triplets of numbers with the difference of 11 within each row/line in the excel spreedsheet. three any numbers (x,y,z) whose difference is 11 , in other words z-y=11 , y-x=11. I use excel 2007. I tried it by using this code below:
Code:
[COLOR=#660066][FONT=inherit]Sub[/FONT][/COLOR][COLOR=#000000][FONT=inherit] FIND1[/FONT][/COLOR][COLOR=#666600][FONT=inherit]()[/FONT][/COLOR]
[COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Option[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Explicit[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Dim[/FONT][/COLOR][COLOR=#000000][FONT=inherit] lngRow [/FONT][/COLOR][COLOR=#660066][FONT=inherit]As[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Long[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Dim[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#660066][FONT=inherit]As[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Integer[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
lngRow [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Do[/FONT][/COLOR][COLOR=#660066][FONT=inherit]While[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Not[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#008800][FONT=inherit]""[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]For[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#660066][FONT=inherit]To[/FONT][/COLOR][COLOR=#006666][FONT=inherit]4[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]If[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Abs[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]-[/FONT][/COLOR][COLOR=#000000][FONT=inherit] _
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#666600][FONT=inherit]))[/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#006666][FONT=inherit]11[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Then[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]If[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Abs[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]-[/FONT][/COLOR][COLOR=#000000][FONT=inherit] _
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]2[/FONT][/COLOR][COLOR=#666600][FONT=inherit]))[/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#006666][FONT=inherit]11[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Then[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]7[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#000000][FONT=inherit] _
[/FONT][/COLOR][COLOR=#008800][FONT=inherit]"("[/FONT][/COLOR][COLOR=#666600][FONT=inherit]&[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]&[/FONT][/COLOR][COLOR=#008800][FONT=inherit]", "[/FONT][/COLOR][COLOR=#666600][FONT=inherit]&[/FONT][/COLOR][COLOR=#000000][FONT=inherit] _
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]&[/FONT][/COLOR][COLOR=#008800][FONT=inherit]", "[/FONT][/COLOR][COLOR=#666600][FONT=inherit]&[/FONT][/COLOR][COLOR=#000000][FONT=inherit] _
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Cells[/FONT][/COLOR][COLOR=#666600][FONT=inherit]([/FONT][/COLOR][COLOR=#000000][FONT=inherit]lngRow[/FONT][/COLOR][COLOR=#666600][FONT=inherit],[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]2[/FONT][/COLOR][COLOR=#666600][FONT=inherit])[/FONT][/COLOR][COLOR=#666600][FONT=inherit]&[/FONT][/COLOR][COLOR=#008800][FONT=inherit]")"[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]End[/FONT][/COLOR][COLOR=#660066][FONT=inherit]If[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]End[/FONT][/COLOR][COLOR=#660066][FONT=inherit]If[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Next[/FONT][/COLOR][COLOR=#000000][FONT=inherit] intCol
lngRow [/FONT][/COLOR][COLOR=#666600][FONT=inherit]=[/FONT][/COLOR][COLOR=#000000][FONT=inherit] lngRow [/FONT][/COLOR][COLOR=#666600][FONT=inherit]+[/FONT][/COLOR][COLOR=#006666][FONT=inherit]1[/FONT][/COLOR][COLOR=#000000][FONT=inherit]
[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Loop[/FONT][/COLOR][COLOR=#660066][FONT=inherit]End[/FONT][/COLOR][COLOR=#660066][FONT=inherit]Sub[/FONT][/COLOR]
this code did the calculation only for some rows of input data posted bellow. It didn't do the calculation until the end of input data, it seems to stop in the middle of of input data and it's omiting some results . For example, it didn't show one the results (27,38,49) such as from the input data [TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl66, width: 64"]10[/TD]
[TD="class: xl66, width: 64"]27[/TD]
[TD="class: xl66, width: 64"]38[/TD]
[TD="class: xl66, width: 64"]40[/TD]
[TD="class: xl66, width: 64"]49[/TD]
[TD="class: xl66, width: 64"]55[/TD]
[/TR]
</tbody>[/TABLE]
i used as general input data the list bellow:
Code:
[TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl66, width: 64"][TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl66, width: 64"]10[/TD]
[TD="class: xl66, width: 64"]27[/TD]
[TD="class: xl66, width: 64"]38[/TD]
[TD="class: xl66, width: 64"]40[/TD]
[TD="class: xl66, width: 64"]49[/TD]
[TD="class: xl66, width: 64"]55[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"][/TD]
[TD="class: xl66, width: 64"][/TD]
[/TR]
</tbody>[/TABLE]
8 11 22 33 44 55
[TABLE="width: 384"]
<tbody>[TR]
[TD="class: xl66, width: 64"]78[/TD]
[TD="class: xl66, width: 64"]88[/TD]
[TD="class: xl66, width: 64"]89[/TD]
[TD="class: xl66, width: 64"]90[/TD]
[TD="class: xl66, width: 64"]95[/TD]
[TD="class: xl66, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]64[/TD]
[TD="class: xl67, width: 64"]76[/TD]
[TD="class: xl67, width: 64"]82[/TD]
[TD="class: xl67, width: 64"]84[/TD]
[TD="class: xl67, width: 64"]93[/TD]
[TD="class: xl67, width: 64"]97[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]67[/TD]
[TD="class: xl66, width: 64"]74[/TD]
[TD="class: xl66, width: 64"]79[/TD]
[TD="class: xl66, width: 64"]85[/TD]
[TD="class: xl66, width: 64"]91[/TD]
[TD="class: xl66, width: 64"]99[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]64[/TD]
[TD="class: xl67, width: 64"]67[/TD]
[TD="class: xl67, width: 64"]78[/TD]
[TD="class: xl67, width: 64"]83[/TD]
[TD="class: xl67, width: 64"]93[/TD]
[TD="class: xl67, width: 64"]98[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]73[/TD]
[TD="class: xl66, width: 64"]87[/TD]
[TD="class: xl66, width: 64"]92[/TD]
[TD="class: xl66, width: 64"]98[/TD]
[TD="class: xl66, width: 64"]99[/TD]
[TD="class: xl66, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]73[/TD]
[TD="class: xl67, width: 64"]74[/TD]
[TD="class: xl67, width: 64"]75[/TD]
[TD="class: xl67, width: 64"]76[/TD]
[TD="class: xl67, width: 64"]80[/TD]
[TD="class: xl67, width: 64"]93[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]73[/TD]
[TD="class: xl66, width: 64"]85[/TD]
[TD="class: xl66, width: 64"]92[/TD]
[TD="class: xl66, width: 64"]94[/TD]
[TD="class: xl66, width: 64"]97[/TD]
[TD="class: xl66, width: 64"]99[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]75[/TD]
[TD="class: xl67, width: 64"]83[/TD]
[TD="class: xl67, width: 64"]84[/TD]
[TD="class: xl67, width: 64"]94[/TD]
[TD="class: xl67, width: 64"]99[/TD]
[TD="class: xl67, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]69[/TD]
[TD="class: xl66, width: 64"]70[/TD]
[TD="class: xl66, width: 64"]73[/TD]
[TD="class: xl66, width: 64"]77[/TD]
[TD="class: xl66, width: 64"]98[/TD]
[TD="class: xl66, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]79[/TD]
[TD="class: xl67, width: 64"]81[/TD]
[TD="class: xl67, width: 64"]86[/TD]
[TD="class: xl67, width: 64"]87[/TD]
[TD="class: xl67, width: 64"]95[/TD]
[TD="class: xl67, width: 64"]98[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]78[/TD]
[TD="class: xl66, width: 64"]79[/TD]
[TD="class: xl66, width: 64"]83[/TD]
[TD="class: xl66, width: 64"]87[/TD]
[TD="class: xl66, width: 64"]93[/TD]
[TD="class: xl66, width: 64"]94[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]56[/TD]
[TD="class: xl67, width: 64"]63[/TD]
[TD="class: xl67, width: 64"]65[/TD]
[TD="class: xl67, width: 64"]81[/TD]
[TD="class: xl67, width: 64"]88[/TD]
[TD="class: xl67, width: 64"]89[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]79[/TD]
[TD="class: xl66, width: 64"]82[/TD]
[TD="class: xl66, width: 64"]84[/TD]
[TD="class: xl66, width: 64"]88[/TD]
[TD="class: xl66, width: 64"]91[/TD]
[TD="class: xl66, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]76[/TD]
[TD="class: xl67, width: 64"]81[/TD]
[TD="class: xl67, width: 64"]83[/TD]
[TD="class: xl67, width: 64"]85[/TD]
[TD="class: xl67, width: 64"]86[/TD]
[TD="class: xl67, width: 64"]97[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]54[/TD]
[TD="class: xl66, width: 64"]65[/TD]
[TD="class: xl66, width: 64"]73[/TD]
[TD="class: xl66, width: 64"]92[/TD]
[TD="class: xl66, width: 64"]94[/TD]
[TD="class: xl66, width: 64"]97[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]59[/TD]
[TD="class: xl67, width: 64"]63[/TD]
[TD="class: xl67, width: 64"]73[/TD]
[TD="class: xl67, width: 64"]78[/TD]
[TD="class: xl67, width: 64"]91[/TD]
[TD="class: xl67, width: 64"]94[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]78[/TD]
[TD="class: xl66, width: 64"]79[/TD]
[TD="class: xl66, width: 64"]92[/TD]
[TD="class: xl66, width: 64"]96[/TD]
[TD="class: xl66, width: 64"]97[/TD]
[TD="class: xl66, width: 64"]98[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]85[/TD]
[TD="class: xl67, width: 64"]91[/TD]
[TD="class: xl67, width: 64"]92[/TD]
[TD="class: xl67, width: 64"]96[/TD]
[TD="class: xl67, width: 64"]97[/TD]
[TD="class: xl67, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]82[/TD]
[TD="class: xl66, width: 64"]86[/TD]
[TD="class: xl66, width: 64"]94[/TD]
[TD="class: xl66, width: 64"]98[/TD]
[TD="class: xl66, width: 64"]99[/TD]
[TD="class: xl66, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]72[/TD]
[TD="class: xl67, width: 64"]75[/TD]
[TD="class: xl67, width: 64"]84[/TD]
[TD="class: xl67, width: 64"]90[/TD]
[TD="class: xl67, width: 64"]93[/TD]
[TD="class: xl67, width: 64"]97[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]75[/TD]
[TD="class: xl66, width: 64"]77[/TD]
[TD="class: xl66, width: 64"]89[/TD]
[TD="class: xl66, width: 64"]92[/TD]
[TD="class: xl66, width: 64"]97[/TD]
[TD="class: xl66, width: 64"]99[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]84[/TD]
[TD="class: xl67, width: 64"]85[/TD]
[TD="class: xl67, width: 64"]93[/TD]
[TD="class: xl67, width: 64"]94[/TD]
[TD="class: xl67, width: 64"]95[/TD]
[TD="class: xl67, width: 64"]100[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]60[/TD]
[TD="class: xl66, width: 64"]64[/TD]
[TD="class: xl66, width: 64"]77[/TD]
[TD="class: xl66, width: 64"]78[/TD]
[TD="class: xl66, width: 64"]89[/TD]
[TD="class: xl66, width: 64"]99[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]59[/TD]
[TD="class: xl67, width: 64"]66[/TD]
[TD="class: xl67, width: 64"]75[/TD]
[TD="class: xl67, width: 64"]86[/TD]
[TD="class: xl67, width: 64"]94[/TD]
[TD="class: xl67, width: 64"]95[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]88[/TD]
[TD="class: xl66, width: 64"]92[/TD]
[TD="class: xl66, width: 64"]93[/TD]
[TD="class: xl66, width: 64"]94[/TD]
[TD="class: xl66, width: 64"]95[/TD]
[TD="class: xl66, width: 64"]98[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]53[/TD]
[TD="class: xl67, width: 64"]66[/TD]
[TD="class: xl67, width: 64"]78[/TD]
[TD="class: xl67, width: 64"]81[/TD]
[TD="class: xl67, width: 64"]88[/TD]
[TD="class: xl67, width: 64"]92[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]75[/TD]
[TD="class: xl66, width: 64"]82[/TD]
[TD="class: xl66, width: 64"]84[/TD]
[TD="class: xl66, width: 64"]86[/TD]
[TD="class: xl66, width: 64"]91[/TD]
[TD="class: xl66, width: 64"]98[/TD]
[/TR]
[TR]
[TD="class: xl67, width: 64"]67[/TD]
[TD="class: xl67, width: 64"]68[/TD]
[TD="class: xl67, width: 64"]73[/TD]
[TD="class: xl67, width: 64"]85[/TD]
[TD="class: xl67, width: 64"]89[/TD]
[TD="class: xl67, width: 64"]96[/TD]
[/TR]
[TR]
[TD="class: xl66, width: 64"]84[/TD]
[TD="class: xl66, width: 64"]85[/TD]
[TD="class: xl66, width: 64"]86[/TD]
[TD="class: xl66, width: 64"]87[/TD]
[TD="class: xl66, width: 64"]93[/TD]
[TD="class: xl66, width: 64"]96[/TD]
[/TR]
</tbody>[/TABLE]
Can someone help me?
Many Thanks