excel - IfElse and use of variables? -


I need 20 lines of loop queue and adding an equation in the worksheet which is different depending on the variable If I'm using ... if statement, and I think I need to declare the variable because I'm just popping up the second line of data.

My code:

  while the counter & lt; 20 counter = counter + 1 if CNUM = 269 and six = 7168 then NTOLL = ("= (C2 * 35) / 1000") range ("E2"). Value = NTLL ALSIF CNUM = 269 and encode = 7181 then Anotocol = ("= (C2 * 2.5) / 1000") Category ("E2") Value = NTLL ALSIF CNUM = 269 and SCOD = 7183 then NTT = ("= (2 * (D2-C2)) / 1000 + 50" range ("E2"). Value = NTL and Loop  

Do I declare only the value of one category for C2, D2 and E2 to do this work?

Which

It is working but two things:

First of all, because CNM and Scod are not changing within the loop, they always have the same value, so only the first match status for each match will be ever received

Secondly, if you If you want to increase the rows, then you must include 'counter' to increase the row elements of your 'range' statement. :

  by counting & lt; 20 counter = counter + 1 if cnum = 269 and skode = 7168 then the annotale = ("= (c 2 * 35) / 1000") cell (counter + 1, 5). Price = NTLL EEIF CNUM = 269 and SCOD = 7181 then coefficient = ("= (C2 * 2.5) / 1000") cells (counter + 1, 5). Price = NTOL FNEF = 269 and SCOD = 7183 then NTotal = ("= (2 * (D2-C2) / 1000 + 50") cells (counter + 1, 5). Value = NTotal end if you read too 


Comments