mardi 26 juillet 2016

VBA loop one cell upward until cell not equal "" and a cell incorporate two IF functions

I'm really sorry but I'm totally new to VBA, learn it by myself without no one to teach and I have project deadline coming up in few days so in desperate and hopeless mode now. Been struggling to find the answer for days but still couldn't come up with any.

Here is the problem: refer the image

Ok so for Column E If B = "S" Then E = "" // null

If B = "F" Then E = (Reverse Rank x PREVIOUS Adjusted Rank + no of failure + 1)/(Reverse Rank + 1)

or in formula excel format

E5 = ((D5*E4)+($K$1+1))/(D5+1)

So the problem lies on the PREVIOUS adjusted rank in the formula. Say, to get value of E5 it needs value of E4 BUT if E4 = "" so it has to go one cell upward. If one cell upward is also ="", it has to go one cell upward again until is not equal <> "". The problem is I'm not sure what function is right to use. I think it would be IF and LOOP but I don't understand how to write the condition. Like I said I'm totally new and time constraints cause me anxiety. Also, if you notice, for Column E there are two IFs function I suppose? One is E is depended on Column B. If Range("B2:B" & lastRow) = "S" or "F" and one is if E="" or <> "" How I incorporated with that?

I am sorry if I break the rules, I'm trying my luck here and it is my last resort >_<

Aucun commentaire:

Enregistrer un commentaire