Excel VBA Result based on Multiple Column & Conditions

bobbyexcel

Board Regular
Joined
Nov 21, 2019
Messages
88
Office Version
  1. 365
Platform
  1. Windows
Need some help on the below requirement. Please help me..

1654203219235.png


I want to update the Column E (Final Status) based on below Condition..
1. Col A & Col C should be equal
2. Col E should have Success / Failed ( don't consider any text other than Success or Failed)
3. if above 2 qualifies then consider the highest value (or nearest to 1) Status(col B) to be applied to all the cells in Col E for the matched cells (from point 1 & 2 above)

Then the final result should come as..

1654203706262.png
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
I'm placing one more column called Rank which defines the top Rank based on my above mentioned criteria (Rank results comes from countifs). So shall we write a code for my requirement..

update the Column E (Final Status) based on below Condition..
1. Update only to the rows that Col A & Col C are equal
2. Col E should have Success / Failed ( don't consider any text other than Success or Failed)
3. if above 2 qualifies then consider the Rank 1 Status(col B) to be applied to all the cells in Col E for the matched cells (from point 1 & 2 above)

1654207487189.png
 
Upvote 0
i hate this kind of questions where the description and the outcome are different.
BobbyExcel

bobbyExcel.xlsb
ABCDEFG
1JOBSTATUSSTARTENDFINALCALCULrow
2XYZFAILED05-apr-2205-apr-22SUCCESS-20,0597
3XYZSUCCESS05-apr-2206-apr-22SUCCESS-20,7503
4ABCFAILED05-apr-2205-apr-22SUCCESS-50,0597
5ABCSUCCESS05-apr-2206-apr-22SUCCESS-50,7503
6ABCSUCCESS05-apr-2206-apr-22SUCCESS-50,625
7
Jobs
 
Upvote 0
@@BSALV Not sure if I missed anything.. and sorry for the confusion.. could you please help.. Did I miss anything from your reply ??
 
Upvote 0
isn't it obvious ? i have 5 times Success and you have 1 Fail, 2 NA and 2 Success or 2 Fails and 3 Success.
So my answer to your question is wrong = we don't speak the same language.
(Column D has no importance)
 
Upvote 0
Re your conditions: Col 1 has a Name in it. Col 3 has a Date in it. How can they be equal.

The test for Col 2 is if it equals "Success" if I understand it. Anything else is a false.

And regarding col 3, you refer to the highest number in Col B, which doesn't contain a number, and I'm not sure what the comparison to all the rows in columns 4 and 5 are about.

Could you refine your testing using values that are shown in your example and explain how they affect the outcome.
 
Upvote 0
Question Counting Rows as 1 for first Data Row:
Cell(2,E) = "NA" and result is "Failed".
Cell(4,E) = "NA" and the result is "Success".

I haven't found a set of conditions from the data to test for this difference.
 
Upvote 0
Question Counting Rows as 1 for first Data Row:
Cell(2,E) = "NA" and result is "Failed".
Cell(4,E) = "NA" and the result is "Success".

I haven't found a set of conditions from the data to test for this difference.
Sorry for the confusion.. here is my explanation ..

update the Column E (Final Status) based on below Condition..
1. Update only to the rows that Col A & Col C are equal. (In the sense, if the row 1 & 2 has Job name XYZ and Start Date is 05 Apr then proceed for step 2)
2. Col E should have Success / Failed ( don't consider any text other than Success or Failed).. then check step 3
3. if above 2 qualifies then consider the Rank 1 from Col G. If the Col G has Rank 1 then pick the status from Col B of the row and apply the same to the cells that matches the rows from point 1 & 2.

Hope you got my point..
 
Upvote 0
Could add a new row to your example showing what the new rank is for each row is after calculation.
Sorry I'm so dense about this, but I haven't really figured out exactly what you're looking for.
But if I you show me exactly what you want, then I can figure out how to code for it for you.

And one more thing: I'm not excactly sure about what you're doing with numbers from the Calculation column. Perhaps a column showing the results of that testing as well.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

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