高手帮我编个EXCEL的语句吧,谢谢啦

来源:百度知道 编辑:UC知道 时间:2024/07/05 09:08:54
如果A1>B1,C1<D1,那么将C1值与D1值互换

要用VBA了,以下代码是输完D1中的数据后,就按你所列的条件执行并返回结果。
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Address = "$D$1" Then
If [A1] > [B1] And [D1] > [C1] Then
[E1] = [C1]
[C1] = [D1]
[D1] = [E1]
[E1] = ""
End If
End If
End Sub

sub cd_change()

dim x
if cells(1,1)>cells(1,2) and cells(1,3)<cells(1,4) then
x=cells(1,3)
cells(1,3)=cells(1,4)
cells(1,4)=x
end if

end sub

要用VBA吗?

没分啊