excel vba - Conditional If statement to set cells equal to 0 -
i have spreadsheet on 6000 rows , 300 columns. need know how write code in vba allow me read cells in column , if says "no" sets 3 cells right of equal zero. there no error when debug it, error in cell.offset line. thoughts?
thank in advance
sub macro1() dim rng range dim cell object sheets("sheet1") set rng = .range("c1:c6000") each cell in rng if cell.value = "no" cell.offset(0, 1).value = 0 exit end if next end end sub
borrowing chuff's code:
sub setto0ifno() dim rng range dim lastrow long dim cell range sheets("sheet1") lastrow = .range("a" & .rows.count).end(xlup).row set rng = .range("a1:a" & lastrow) each cell in rng if cell.value = "no" 'cell.offset(0, 3).value = 0 cell.range("b1:d1").value = 0 end if next end end sub
Comments
Post a Comment