myghetto
12-05-2011, 05:57 AM
Hi,
I have a basic knowledge of VBA and Excel. I have been trying to write a code to determine this:
Col1.....Col2.....Col3.....Col4.....Col5 (Y)
ABC.....F123.....160.....120
ABC.....F123.....120.....120
ABC.....F125.....110.....120
BCB.....F125.....58.....160
BCB.....F125.....55.....120
BCB.....F127.....56.....120
Basically I am looking for a code to determine the largest number from Column 3 (Col3) based on the two different groups in Column 1 (Col1) and the sub-group Column 2 (Col2). ABC is in the same group, Column 2 is the subgroup. IF there in the group Column 1, there are two F123, then I want to compare the numbers in Column 3 to find the biggest number. In this case it's 160. I want to be able to put a "Y" in Column 5 in the same row as the number 160 to show its the biggest. The ACB F125 is by itself so it is automatically accepted as the largest number and a "Y" will be inserted in Column 5 in the same row. Then I want the code to look at the next group BCB. Since there are two F125s again, we compare the 58 and 55. Obviously 58 is larger but I want the difference of more than 10 to be considered so since 58 and 55 is a difference of 3, we look at the next column, Column 4. Here we see 160 is bigger than 120 so a Y will be put in the BCB F125 58 160 row. I would really appreciate it if someone could help me out as I have tried to write it the inefficient way and its still not working. Thank you in advance.
I have a basic knowledge of VBA and Excel. I have been trying to write a code to determine this:
Col1.....Col2.....Col3.....Col4.....Col5 (Y)
ABC.....F123.....160.....120
ABC.....F123.....120.....120
ABC.....F125.....110.....120
BCB.....F125.....58.....160
BCB.....F125.....55.....120
BCB.....F127.....56.....120
Basically I am looking for a code to determine the largest number from Column 3 (Col3) based on the two different groups in Column 1 (Col1) and the sub-group Column 2 (Col2). ABC is in the same group, Column 2 is the subgroup. IF there in the group Column 1, there are two F123, then I want to compare the numbers in Column 3 to find the biggest number. In this case it's 160. I want to be able to put a "Y" in Column 5 in the same row as the number 160 to show its the biggest. The ACB F125 is by itself so it is automatically accepted as the largest number and a "Y" will be inserted in Column 5 in the same row. Then I want the code to look at the next group BCB. Since there are two F125s again, we compare the 58 and 55. Obviously 58 is larger but I want the difference of more than 10 to be considered so since 58 and 55 is a difference of 3, we look at the next column, Column 4. Here we see 160 is bigger than 120 so a Y will be put in the BCB F125 58 160 row. I would really appreciate it if someone could help me out as I have tried to write it the inefficient way and its still not working. Thank you in advance.