# Question about If Statment in Excel

Is it possible to have an if statement in excel that will do the following and if so how would you write it?
I have column B and Column M.

I want the if statement to go down column B.
I want the if statement to do if possible to see if column M2 is 0 if it is to do the following in B2.
Copy B1 formula into B2 and if M2 is not 0 to use another formula.

When I say copy B1 formula into B2, I mean do not automatic change the column letters or numbers, others words if it days B1 = G1 + H1 I want it to stay B1 = G1 + H1 not B2 = G2 + H2
Because I want the outcome that was in B1 to be in B2. If this possible I will be taking the formula from B1 to B90

I hope this is clear enough.
###### Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Commented:
Use \$ to lock the cell references when copying.
In B2: =IF(M2=0,\$B\$1,"another formula")

Experts Exchange Solution brought to you by

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

IT ArchitectCommented:
If i understood correctly, if M(any row) is equal to 0 then copy the value from one row above, then this formula will work:

``````=IF(M2=0;INDIRECT("B"&ROW()-1);"another formula")
``````

but if you always want to show the value from B1 then the Ejgil formula will do the trick..
Author Commented:
I am trying to use Ejgil formula
=IF(F15=0,\$B\$14,"=((16*B14)-((G15-F15)/(3500/16)))/16")
But when I put an amount into F15 it show wrong data. it looks like it is formatting that cell
I have to copy a blank cell back to F15
Excel VBA DeveloperCommented:
starview,

You're now referencing a difference column altogether (column F, cell F15) and you're on a different row (15 vs. 2).

You just need to remove the quotes in the [value_if_false] argument:
=IF(F15=0,\$B\$14,((16*B14)-((G15-F15)/(3500/16)))/16)

Regards,
-Glenn
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Excel

From novice to tech pro — start learning today.