Calculations

R

Ryan W

In MS Access I was able to do

if A + B = C then
do action
else
do another action
end if

Can I do the same in Excel for example:

if Cell.A1 + Cell.A2 = Cell.A3 then


What would the VBA look like?
Thank you for your time,
Ryan
 
M

Mike H

One way

If Range("A1") + Range("A2") = Range("A3") Then
'do things
Else
'Do different things
End If

Mike
 
D

Don Guillett

I did this using several variations so you can see that there is more than
one way to skin the cat.

sub doit()
if range("a1")+cells(2,1)=cells(3,"a") then
msgbox "OK"
else
msgbox "not ok"
end if
 
M

Mike H

A neat way to demonstrate 3 ways :)

Don Guillett said:
I did this using several variations so you can see that there is more than
one way to skin the cat.

sub doit()
if range("a1")+cells(2,1)=cells(3,"a") then
msgbox "OK"
else
msgbox "not ok"
end if

--
Don Guillett
Microsoft MVP Excel
SalesAid Software
[email protected]
 
Top