---
title: "Compare two cells with IF | PracticeExcel"
description: "Practice IF in a live spreadsheet: compare spending with the budget and flag the departments that are over."
canonical_url: "https://practiceexcelonline.com/practice/if/if-compare-two-cells"
locale: en
meta:
  "og:description": "Practice IF in a live spreadsheet: compare spending with the budget and flag the departments that are over."
  "og:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_Compare%2Btwo%2Bcells%2Bwith%2BIF%2Cdescription_~UHJhY3RpY2UgSUYgaW4gYSBsaXZlIHNwcmVhZHNoZWV0OiBjb21wYXJlIHNwZW5kaW5nIHdpdGggdGhlIGJ1ZGdldCBhbmQgZmxhZyB0aGUgZGVwYXJ0bWVudHMgdGhhdCBhcmUgb3Zlci4%2Ceyebrow_IF%2Csite_practiceexcel%2Cprops_eyJncmlkIjp7ImNvbHMiOlsiQSIsIkIiLCJDIiwiRCJdLCJyb3dzIjpbeyJuIjoxLCJjZWxscyI6WyJEZXBhcnRtZW50IiwiQnVkZ2V0IiwiU3BlbnQiLCJTdGF0dXMiXX0seyJuIjoyLCJjZWxscyI6WyJNYXJrZXRpbmciLCI1MDAwMCIsIjU0MjAwIiwiIl19LHsibiI6MywiY2VsbHMiOlsiU2FsZXMiLCI4MDAwMCIsIjc2NTAwIiwiIl19LHsibiI6NCwiY2VsbHMiOlsiSVQiLCIxMjAwMDAiLCIxMTgzMDAiLCIiXX0seyJuIjo1LCJjZWxscyI6WyJIUiIsIjMwMDAwIiwiMzE5MDAiLCIiXX1dLCJ0YXJnZXQiOlsxLDNdfX0%2Cp_Ii9wcmFjdGljZS9pZi9pZi1jb21wYXJlLXR3by1jZWxscyI%2Cs_87_vXRJiiCvpKgmv.png"
  "og:image:height": "600"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "Compare two cells with IF | PracticeExcel"
  "twitter:image": "https://practiceexcelonline.com/_og/d/c_Page%2Ctitle_Compare%2Btwo%2Bcells%2Bwith%2BIF%2Cdescription_~UHJhY3RpY2UgSUYgaW4gYSBsaXZlIHNwcmVhZHNoZWV0OiBjb21wYXJlIHNwZW5kaW5nIHdpdGggdGhlIGJ1ZGdldCBhbmQgZmxhZyB0aGUgZGVwYXJ0bWVudHMgdGhhdCBhcmUgb3Zlci4%2Ceyebrow_IF%2Csite_practiceexcel%2Cprops_eyJncmlkIjp7ImNvbHMiOlsiQSIsIkIiLCJDIiwiRCJdLCJyb3dzIjpbeyJuIjoxLCJjZWxscyI6WyJEZXBhcnRtZW50IiwiQnVkZ2V0IiwiU3BlbnQiLCJTdGF0dXMiXX0seyJuIjoyLCJjZWxscyI6WyJNYXJrZXRpbmciLCI1MDAwMCIsIjU0MjAwIiwiIl19LHsibiI6MywiY2VsbHMiOlsiU2FsZXMiLCI4MDAwMCIsIjc2NTAwIiwiIl19LHsibiI6NCwiY2VsbHMiOlsiSVQiLCIxMjAwMDAiLCIxMTgzMDAiLCIiXX0seyJuIjo1LCJjZWxscyI6WyJIUiIsIjMwMDAwIiwiMzE5MDAiLCIiXX1dLCJ0YXJnZXQiOlsxLDNdfX0%2Cp_Ii9wcmFjdGljZS9pZi9pZi1jb21wYXJlLXR3by1jZWxscyI%2Cs_87_vXRJiiCvpKgmv.png"
---

> Index of every page on this site: [llms.txt](https://practiceexcelonline.com/llms.txt)

# **Compare two cells with IF**

**Premium**

In D2, show "Over budget" if the amount spent in C2 is more than the budget in B2, and "OK" if not.

D2fx

|  | A | B | C | D | E | F |
| --- | --- | --- | --- | --- | --- | --- |
| 1 | Department | Budget | Spent | Status |  | |
| 2 | Marketing | 50000 | 54200 |  |  | |
| 3 | Sales | 80000 | 76500 |  |  | |
| 4 | IT | 120000 | 118300 |  |  | |
| 5 | HR | 30000 | 31900 |  |  | |
| 6 |  |  |  |  |  | |
| 7 |  |  |  |  |  | |
| 8 |  |  |  |  |  | |

**Premium lesson**

## **Unlock IF and every other lesson**

This is a premium lesson. Premium lets you solve it and every other lesson, take the timed mock tests, and earn certificates you can share on LinkedIn.

Next with premium:**AND and OR****IFS and SWITCH**

It comes up in this mock test: [**Excel assessment (Indeed format)**](https://practiceexcelonline.com/tests/indeed-excel-assessment)

[**See plans, from $5/month**](https://practiceexcelonline.com/pricing) [**Already premium? Sign in**](https://practiceexcelonline.com/login?next=/practice/if/if-compare-two-cells)

Need help?

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://practiceexcelonline.com/#identity","@type":"Organization","name":"PracticeExcel","url":"https://practiceexcelonline.com/","logo":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/#website","@type":"WebSite","inLanguage":"en-US","name":"PracticeExcel","url":"https://practiceexcelonline.com/","alternateName":["Practice Excel Online","PracticeExcelOnline.com"],"publisher":{"@id":"https://practiceexcelonline.com/#identity"},"workTranslation":{"@id":"https://excelopgaver.dk/#website"}},{"@id":"https://practiceexcelonline.com/practice/if/if-compare-two-cells#webpage","description":"Practice IF in a live spreadsheet: compare spending with the budget and flag the departments that are over.","name":"Compare two cells with IF","url":"https://practiceexcelonline.com/practice/if/if-compare-two-cells","@type":["WebPage","FAQPage"],"breadcrumb":{"@id":"https://practiceexcelonline.com/practice/if/if-compare-two-cells#breadcrumb"},"isPartOf":{"@id":"https://practiceexcelonline.com/#website"},"mainEntity":[{"@id":"https://practiceexcelonline.com/practice/if/if-compare-two-cells#/schema/question/1"}],"potentialAction":[{"@type":"ReadAction","target":["https://practiceexcelonline.com/practice/if/if-compare-two-cells"]}],"primaryImageOfPage":{"@id":"https://practiceexcelonline.com/#logo"}},{"@id":"https://practiceexcelonline.com/practice/if/if-compare-two-cells#breadcrumb","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","name":"Home","item":"https://practiceexcelonline.com","position":1},{"@type":"ListItem","name":"Excel practice exercises","item":"https://practiceexcelonline.com/practice","position":2},{"@type":"ListItem","name":"IF","item":"https://practiceexcelonline.com/practice/if","position":3},{"@type":"ListItem","name":"Compare two cells with IF","position":4}]},{"@id":"https://practiceexcelonline.com/practice/if/if-compare-two-cells#/schema/question/1","@type":"Question","inLanguage":"en-US","name":"How do I compare two cells with IF in Excel?","acceptedAnswer":{"@type":"Answer","text":"Put the comparison in the test, =IF(C2>B2,\"Over budget\",\"OK\"). Any of =, \u003C>, >, \u003C, >= and \u003C= works."}},{"@id":"https://practiceexcelonline.com/practice/if/if-compare-two-cells#/schema/learning-resource/1","@type":"LearningResource","description":"Practice IF in a live spreadsheet: compare spending with the budget and flag the departments that are over.","educationalLevel":"beginner","isAccessibleForFree":false,"learningResourceType":"exercise","name":"Compare two cells with IF","teaches":"IF"},{"@id":"https://practiceexcelonline.com/#logo","@type":"ImageObject","caption":"PracticeExcel","contentUrl":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png","inLanguage":"en-US","url":"https://practiceexcelonline.com/brand/practiceexcel/icon-512.png"}]}
```

## Sitemap

See the full [sitemap](https://practiceexcelonline.com/sitemap.md) for all pages.
