基于另一个小区的值改变小区的值

我有2000+行的单,在单元格S我有一些价值,基于单元格我需要改变单元格中的值

例如,如果单元S的值小于单元V = 241,那么V = 240

代码需要检查每一行

TNX

需要在vba中完成

试试这个:

 Sub test() Dim lastrow As Long 'change Sheet1 to suit With ThisWorkbook.Worksheets("Sheet1") 'find lastrow in column S lastrow = .Cells(.Rows.Count, "S").End(xlUp).Row 'change V1 to, say, V2 if your data starts from V2 With Range("V1:V" & lastrow) 'calculate result with formula .Formula = "=IF(S1<3552,241,240)" 'change S1 to, say, S2 if your data starts from S2 'rewrite formula with values .Value = .Value End With End With End Sub