我想问一下将值放入单元格A和单元格B将自动更改的最佳方法是什么?例如:条件是当单元格A为“食物”,并且在单元格A中输入食物后,单元格B将自动将值输入为“汉堡”。
这可以通过VBA或公式来完成。
VBA:
右键点击标签,然后选择查看代码:
将此粘贴到:
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Column = 1 Then 'Check the user entered data into column A
If UCase(Target.Text) = "FOOD" Then Target.Offset(0, 1).Formula = "Burger" 'Update 1 cell to the right of the cell the user modified (called Target) if the cell text is "Food"
End If
End Sub
Excel公式:
=IF(A1="FOOD","Burger","")
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句