excel 我想要B1=C1+D1 同时B1=C1 但D1等于1 这个怎么解决

发布时间:2019-09-19 11:43:13

excel 我想要B1=C1+D1 同时B1=C1 但D1等于1 这个怎么解决

推荐回答

你是不是要这种效果:

往下看:

不管D1单元格显示什么内容,看编辑栏,实际上它是0  。

代码如下:

Private Sub Worksheet_Change(ByVal Target As Range)

Application.EnableEvents = False

If Target.Address = "$D$1" Then

If Target = 0 Then

Target.NumberFormatLocal = "G/通用格式"

Else

Target.NumberFormatLocal = "[=0]""" & Target & """;G/通用格式"

Target = 0

End If

End If

[b1].NumberFormatLocal = "G/通用格式"

Application.EnableEvents = True

End Sub

这个不可能实现,因为有重复引用。

你是要当 D1=1 时,B1=C1,否则 B1=C1+D1?

B1 的公式:

if(d1=1, c1, c1+d1)

B1=C1+D1 ...................(1)

B1=C1 .............................(2)

(1)-(2)得

D1=0

与你的要求D1=1矛盾

所以你的要求无法满足

以上问题属网友观点,不代表本站立场,仅供参考!