How to Use the Excel Cell Format Formula (4 Methods)

What is Cell Formatting in Excel?

Cell formatting involves adjusting or changing the appearance of a cell without altering its original value.

In this analysis, we’ll work with a dataset containing item names, order IDs, dates, states, and sales.

Dataset


Method 1 – Cell Format Using the TEXT Function

The TEXT function converts a value to text in a specific number format. Let’s explore how to use it:

  1. Syntax: =TEXT(value, format_text)
  2. Example: =TEXT(B5, C5)

In the example above:

  • B5 represents the cell with the value.
  • C5 specifies the format text.

Cell Format Using The TEXT Function

The TEXT function can:

  • Convert negative values (e.g., “-1000” becomes “1000” and vice versa).
  • Display values in scientific notation.
  • Extract day and month names from dates.
  • Add leading zeros to numbers.

To find the sales amount (product of price and quantity) with the text “The Sales is,” use this formula:

="The Sales is "&TEXT(C5*D5, "$###,###.00")

Here, C5 is the price cell, D5 is the quantity, and $###,###.00 is the desired dollar currency format.

Cell Format Using The TEXT Function


Method 2 – Cell Format Using Conditional Formatting

Conditional Formatting is a powerful tool in Excel that changes cell colors based on specified conditions. Let’s explore some specific applications:


2.1. Highlighting Specific Words in the Dataset

Suppose you want to highlight items like TV and states like Ohio in your dataset. Follow these steps:

  • Select the cell range B5:F15.
  • Go to the Home tab, select Conditional Formatting and click on New Rule.

Cell Format Using Conditional Formatting in Excel

  • Choose Use a formula to determine which cells to format.
  • Enter this formula under Format values where this formula is true:

=OR(B5="TV",B5="Ohio")

Here, B5 is the cell of AC.

  • Specify the desired highlighting color and click OK.

Cell Format Using Conditional Formatting in Excel

The output will highlight occurrences of TV and Ohio.

Cell Format Using Conditional Formatting in Excel

To change the color of items from Ohio states, use this formula:

=$E5="Ohio"

Here, E5 is the starting cell of the States field.

Cell Format Using Conditional Formatting in Excel


2.2. Highlighting Dates in the Next 30 Days

To identify and highlight dates within the next 30 days, use this formula in the New Formatting Rule dialog box:

=AND(B5>NOW(),B5<=(NOW()+30))

Here, B5 represents the order date. The formula combines the AND and NOW functions.

Highlighting Dates in Next 30 Days


2.3. Highlighting Missing Values 

You can show missing values by synchronizing lists using conditional formatting. Use these formulas:

=COUNTIF($D$5:$D$11, B5)=0

Here, D5:D11 is the cell range of List 2, and B5 is the starting cell of List 1.

And the formula for list 2 is-

=COUNTIF($B$5:$B$15, D5)=0

Here, B5:B15 is the cell range of List 1 and D5 is the starting cell of List 2.

Highlighting Missing Values


2.4. Applying Multiple Criteria as Cell Format

We can use AND logic with multiple criteria across the entire dataset and highlight the output using conditional formatting.

For instance, let’s highlight items with a price less than or equal to $300 and sales greater than or equal to $2000.

For this, put the following formula in the New Formatting Rule dialog box:

=AND($E5<=300,$G5>=2000)

Here, E5 represents the starting cell for prices, and G5represents the starting cell for sales.

Applying Multiple Criteria

As a result, only 4 items meet the criteria of having a price less than or equal to $300 and sales greater than or equal to $2000.


Method 3 – Cell Format Formula Using VBA Coding

Let’s explore how to apply the VBA Format function to convert values into specific formats:

Step 1: 

Open a module by clicking on the Developer tab, selecting Visual Basic, clicking on Insert and selecting Module.

Step 2: 

Copy the following code into your module:

Sub Format_func()
Range("C5").Value = Format(Range("B5"), "Currency")
Range("C6").Value = Format(Range("B6"), "Long Date")
Range("C7").Value = Format(Range("B7"), "True/False")
Range("C8").Value = Format(Range("B8"), "Standard")
Range("C9").Value = Format(Range("B9"), "Fixed")
Range("C10").Value = Format(Range("B10"), "Long Time")
Range("C11").Value = Format(Range("B11"), "Short Time")
End Sub

Step 3:

Run the code.

Notes:

The following things are essential in the above VBA code.

  • Worksheet name: The worksheet name in this example is “Format_func”.
  • Logic: The Format  function returns values in specific formats.
  • Input Cell: We use cells B5, B6, etc., as input.
  • Output range: The output ranges are C5, C6, etc.

After running the code, the output will be as follows.

Using VBA FORMAT Function


Method 4 – Cell Format Utilizing LEFT, MID, RIGHT, LEN & FIND Functions

RIGHT Function:

  • Removes characters from the left side of the Order ID-Items string.

Formula:

=RIGHT(B5,LEN(B5)-C5)

    • Here, B5 is the cell containing the combined Order ID-Items, and C5 represents the number of characters to remove.

Cell Format Utilizing LEFT, MID, RIGHT, LEN & FIND Function

Formatting Cells in Numeric Format:

  • Converts a combination of text and numbers (Order ID-Items) into numeric format.

Formula:

=VALUE(LEFT(B5,(LEN(B5)-C5)))

    • B5 is the cell containing the combined Order ID-Items, and C5 is the starting cell for Chars.

 

Cell Format Utilizing LEFT, MID, RIGHT, LEN & FIND Function

MID Function:

  • Extracts the last name from the Name of Orderer.

Formula:

=MID(C5,SEARCH(" ",C5)+1,LEN(C5)-SEARCH(" ",C5))

    • Here, C5 is the starting cell of Name of Orderer.

Cell Format Utilizing LEFT, MID, RIGHT, LEN & FIND Function

FIND Function:

  • Retrieves the first name from the Name of Orderer.

Formula:

=MID(C5,1,FIND(" ",C5)-1)

    • Here, C5 is the starting cell of Name of Orderer.

Cell Format Utilizing LEFT, MID, RIGHT, LEN & FIND Function

These unconventional methods can be helpful for extracting and organizing data in specific cell formats.


Download Practice Workbook

You can download the practice workbook from here:


Related Article


<< Go Back to Excel Cell FormatLearn Excel

Get FREE Advanced Excel Exercises with Solutions!
Md. Abdul Kader
Md. Abdul Kader

MD. ABDUL KADER is an engineer with a talent for Excel and a passion for VBA programming. To him, programming is like a time-saving wizard, making data manipulation, file handling, and internet interactions a breeze. His skill set extends to SWM, GIS, RS, and SPSS. He holds a B.Sc in Urban & Regional Planning from Chittagong University of Engineering and Technology and has shifted to become a content developer. In this role, he crafts technical content centred around... Read Full Bio

We will be happy to hear your thoughts

Leave a reply

Advanced Excel Exercises with Solutions PDF

 

 

ExcelDemy
Logo