Applying an Excel VBA single row macro to a cell range -
could explain how macro run on entire columns instead single row of cells please? i.e. check values of each individual cell , perform required calculation , output in respective cell on row.
sub calculate_costs() if cells(2, 7) = "one man" , cells(2, 6) >= cells(2, 5) cells(2, 8) = 6.5 + ((cells(2, 6) - 20) * 0.23) elseif cells(2, 7) = "one man" , cells(2, 6) < cells(2, 5) cells(2, 8) = 6.5 + ((cells(2, 5) - 20) * 0.23) elseif cells(2, 7) = "two man" , cells(2, 6) >= cells(2, 5) cells(2, 8) = 38 + ((cells(2, 6) - 50) * 0.38) elseif cells(2, 7) = "two man" , cells(2, 6) < cells(2, 5) cells(2, 8) = 38 + ((cells(2, 5) - 50) * 0.38) else cells(2, 14) = "this not working" end if end sub
something like:
dim row integer row = 1 while cells(row, 7) <> "" //your original code here 2 replaced row row = row + 1 wend loops through rows in column 7 until hits blank cell.
excel-vba
No comments:
Post a Comment