ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Calculations (https://www.excelbanter.com/excel-programming/417294-calculations.html)

Ryan W

Calculations
 
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

Mike H

Calculations
 
One way

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

Mike

"Ryan W" wrote:

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


Don Guillett

Calculations
 
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

"Ryan W" wrote in message
...
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



Mike H

Calculations
 
A neat way to demonstrate 3 ways :)

"Don Guillett" wrote:

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

"Ryan W" wrote in message
...
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





All times are GMT +1. The time now is 06:16 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com