Calculations

  • Thread starter Thread starter Ryan W
  • Start date Start date
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
 
One way

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

Mike
 
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
 
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
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top