基于另一个单元格的值改变单元格的值 [英] changing value of cell based on value of another cell
本文介绍了基于另一个单元格的值改变单元格的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我拥有2000多行的表单,在单元格S中,我有一些值,基于单元格S,我需要更改单元格V中的值
i have sheet with 2000+ rows, in cell S i have some value, based on cell S i need to change value in cell V
,例如,如果值的单元S为3552比单元格V = 241 else V = 240
for example if value of cell S is < 3552 than cell V= 241 else V=240
代码需要检查每一行
tnx
tnx
推荐答案
需要在vba中完成
need to be done in 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
这篇关于基于另一个单元格的值改变单元格的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文