Microsoft Excel Tutorials

Excel - Formulas on String and range

Excel Formula Tips and Tricks

Excel Formula Tips and Tricks

Count Cells Starting (or Ending) with a Particular String

Count Cells Starting with a String

Say you want to count all cells starting with C:

=COUNTIF(A1:A10,"c*")

Note: "c*" is case insensitive. Hence, it will count cells starting with both "c" or "C".

Suppose you want to find all cells starting with Excel:

=COUNTIF(A1:A10,"excel*")

Count Cells Ending with a String

=COUNTIF(A1:A10,"*c")

Note: "*c" is case insensitive. Hence, it will count cells ending with both "c" or "C".

Suppose you want to find all cells ending with Excel:

=COUNTIF(A1:A10,"*excel")

Count Number of Cells Having Numbers Only

The COUNT function counts only cells that contain numbers.

=COUNT(A1:A10)

Reverse a String

Suppose cell A1 contains "qwerty" and you want to reverse it:

=TEXTJOIN(,,MID(A1,LEN(A1)-SEQUENCE(LEN(A1))+1,1))
=TEXTJOIN(,,MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1))

Reverse Number String

Suppose cell A1 has the number 16709 and you want to reverse it to get 90761:

=SUMPRODUCT(MID(A1,SEQUENCE(LEN(A1)),1)*10^SEQUENCE(LEN(A1))/10)
=--TEXTJOIN(,,MID(A1,LEN(A1)-SEQUENCE(LEN(A1))+1,1))

Reverse a String of Words

Suppose A2 has: "Moscow, London, Paris, Delhi, Washington, Miami, Detroit, Berlin"

You want: "Berlin, Detroit, Miami, Washington, Delhi, Paris, London, Moscow"

=TEXTJOIN(", ",SORTBY(FILTERXML("<t><s>"&SUBSTITUTE(A2,",","</s><s>")&"</s></t>","//s"),SEQUENCE(LEN(A2)-LEN(SUBSTITUTE(A2,","," "))+1),-1))

Reverse a Range of Cells

Suppose you have values in A2:A11 and want to reverse them in column D.

=INDEX(A2:A11,COUNTA(A2:A11)-SEQUENCE(COUNTA(A2:A11))+1)
=INDEX(A2:A11,COUNTA(A2:A11)-ROW(INDIRECT("1:"&COUNTA(A2:A11)))+1)
=SORTBY(FILTER(A2:A11,A2:A11<>""),SEQUENCE(COUNTA(A2:A11)),-1)

Get First Row Number in a Range

=MIN(ROW(D15:Q99))

Get Last Row Number in a Range

=@SORT(ROW(D15:Q99),,-1)
=MAX(ROW(D15:Q99))

Get First Column Number in a Range

=@COLUMN(D15:Q99)
=MIN(COLUMN(D15:Q99))

Get Last Column Number in a Range

=MAX(COLUMN(D15:Q99))

Extract Unique Characters

Suppose A1 contains "abracadabra" and you want the result as "abrcd":

=TEXTJOIN(,,UNIQUE(MID(A1,SEQUENCE(LEN(A1)),1)))
=TEXTJOIN(,,UNIQUE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))

Test Whether a Range Contains Only Numbers

=ISNUMBER(--TEXTJOIN("",1,A1:A10))

Test Whether a Range Contains Only English Alphabets

=NOT(ISERROR(SUM(MATCH(UPPER(A1:A10),CHAR(ROW(65:90)),0))))

Ignore Blanks

=NOT(ISERROR(SUM(MATCH(UPPER(FILTER(A1:A10,A1:A10<>"")),CHAR(ROW(65:90)),0))))

Count Number of Cells Which Are Containing Only Characters

=COUNTIF(A1:A10,"*")

Number of Characters in a String Without Considering Blanks

=LEN(SUBSTITUTE(A1," ",""))

Number of Times a Character Appears in a String

=LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),"a",""))

Count Non-Numbers in a String

Suppose your string in A1 is "abc123def45cd".

=COUNT(IF(ISNUMBER(--MID(A1,SEQUENCE(LEN(A1)),1)),"",0))-(A1="")
=COUNT(IF(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)),"",0))-(A1="")
=SUMPRODUCT(--NOT(ISNUMBER(--MID(A1,SEQUENCE(LEN(A1)),1))))-(A1="")
=SUMPRODUCT(--NOT(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))))-(A1="")

Count Numbers in a String

Suppose you have a string "abc123def43cd" and you want to count numbers in this.

If your string is in A1, use following formula:

=COUNT(--MID(A1,SEQUENCE(LEN(A1)),1))
=COUNT(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))
=SUMPRODUCT(--ISNUMBER(--MID(A1,SEQUENCE(LEN(A1)),1)))
=SUMPRODUCT(--ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))
=SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,ROW(1:10)-1,"")))

Count only Alphabets in a String

Suppose you have a string "Ab?gh123def%h*" and you want to count only Alphabets.

Suppose your string is in A1, put following formula for this:

=SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),CHAR(ROW(INDIRECT("65:90"))),"")))
=SUMPRODUCT(--(ABS(77.5-CODE(MID(UPPER(A1),ROW(INDIRECT("A1:A"&LEN(A1))),1)))<13))

Generate English Alphabets

To generate English alphabets A...Z

=CHAR(SEQUENCE(26,,65))
=CHAR(ROW(65:90))

To generate English alphabets a...z

=CHAR(SEQUENCE(26,,97))
=CHAR(ROW(97:122))

To generate English alphabets in a row

=CHAR(SEQUENCE(,26,65))
=CHAR(SEQUENCE(,26,97))
=TRANSPOSE(CHAR(ROW(65:90)))

Beginner 5 Hours
Excel Formula Tips and Tricks

Excel Formula Tips and Tricks

Count Cells Starting (or Ending) with a Particular String

Count Cells Starting with a String

Say you want to count all cells starting with C:

=COUNTIF(A1:A10,"c*")

Note: "c*" is case insensitive. Hence, it will count cells starting with both "c" or "C".

Suppose you want to find all cells starting with Excel:

=COUNTIF(A1:A10,"excel*")

Count Cells Ending with a String

=COUNTIF(A1:A10,"*c")

Note: "*c" is case insensitive. Hence, it will count cells ending with both "c" or "C".

Suppose you want to find all cells ending with Excel:

=COUNTIF(A1:A10,"*excel")

Count Number of Cells Having Numbers Only

The COUNT function counts only cells that contain numbers.

=COUNT(A1:A10)

Reverse a String

Suppose cell A1 contains "qwerty" and you want to reverse it:

=TEXTJOIN(,,MID(A1,LEN(A1)-SEQUENCE(LEN(A1))+1,1))
=TEXTJOIN(,,MID(A1,LEN(A1)-ROW(INDIRECT("1:"&LEN(A1)))+1,1))

Reverse Number String

Suppose cell A1 has the number 16709 and you want to reverse it to get 90761:

=SUMPRODUCT(MID(A1,SEQUENCE(LEN(A1)),1)*10^SEQUENCE(LEN(A1))/10)
=--TEXTJOIN(,,MID(A1,LEN(A1)-SEQUENCE(LEN(A1))+1,1))

Reverse a String of Words

Suppose A2 has: "Moscow, London, Paris, Delhi, Washington, Miami, Detroit, Berlin"

You want: "Berlin, Detroit, Miami, Washington, Delhi, Paris, London, Moscow"

=TEXTJOIN(", ",SORTBY(FILTERXML("<t><s>"&SUBSTITUTE(A2,",","</s><s>")&"</s></t>","//s"),SEQUENCE(LEN(A2)-LEN(SUBSTITUTE(A2,","," "))+1),-1))

Reverse a Range of Cells

Suppose you have values in A2:A11 and want to reverse them in column D.

=INDEX(A2:A11,COUNTA(A2:A11)-SEQUENCE(COUNTA(A2:A11))+1)
=INDEX(A2:A11,COUNTA(A2:A11)-ROW(INDIRECT("1:"&COUNTA(A2:A11)))+1)
=SORTBY(FILTER(A2:A11,A2:A11<>""),SEQUENCE(COUNTA(A2:A11)),-1)

Get First Row Number in a Range

=MIN(ROW(D15:Q99))

Get Last Row Number in a Range

=@SORT(ROW(D15:Q99),,-1)
=MAX(ROW(D15:Q99))

Get First Column Number in a Range

=@COLUMN(D15:Q99)
=MIN(COLUMN(D15:Q99))

Get Last Column Number in a Range

=MAX(COLUMN(D15:Q99))

Extract Unique Characters

Suppose A1 contains "abracadabra" and you want the result as "abrcd":

=TEXTJOIN(,,UNIQUE(MID(A1,SEQUENCE(LEN(A1)),1)))
=TEXTJOIN(,,UNIQUE(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))

Test Whether a Range Contains Only Numbers

=ISNUMBER(--TEXTJOIN("",1,A1:A10))

Test Whether a Range Contains Only English Alphabets

=NOT(ISERROR(SUM(MATCH(UPPER(A1:A10),CHAR(ROW(65:90)),0))))

Ignore Blanks

=NOT(ISERROR(SUM(MATCH(UPPER(FILTER(A1:A10,A1:A10<>"")),CHAR(ROW(65:90)),0))))

Count Number of Cells Which Are Containing Only Characters

=COUNTIF(A1:A10,"*")

Number of Characters in a String Without Considering Blanks

=LEN(SUBSTITUTE(A1," ",""))

Number of Times a Character Appears in a String

=LEN(A1)-LEN(SUBSTITUTE(LOWER(A1),"a",""))

Count Non-Numbers in a String

Suppose your string in A1 is "abc123def45cd".

=COUNT(IF(ISNUMBER(--MID(A1,SEQUENCE(LEN(A1)),1)),"",0))-(A1="")
=COUNT(IF(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)),"",0))-(A1="")
=SUMPRODUCT(--NOT(ISNUMBER(--MID(A1,SEQUENCE(LEN(A1)),1))))-(A1="")
=SUMPRODUCT(--NOT(ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))))-(A1="")

Count Numbers in a String

Suppose you have a string "abc123def43cd" and you want to count numbers in this.

If your string is in A1, use following formula:

=COUNT(--MID(A1,SEQUENCE(LEN(A1)),1))
=COUNT(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1))
=SUMPRODUCT(--ISNUMBER(--MID(A1,SEQUENCE(LEN(A1)),1)))
=SUMPRODUCT(--ISNUMBER(--MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)))
=SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(A1,ROW(1:10)-1,"")))

Count only Alphabets in a String

Suppose you have a string "Ab?gh123def%h*" and you want to count only Alphabets.

Suppose your string is in A1, put following formula for this:

=SUMPRODUCT(LEN(A1)-LEN(SUBSTITUTE(UPPER(A1),CHAR(ROW(INDIRECT("65:90"))),"")))
=SUMPRODUCT(--(ABS(77.5-CODE(MID(UPPER(A1),ROW(INDIRECT("A1:A"&LEN(A1))),1)))<13))

Generate English Alphabets

To generate English alphabets A...Z

=CHAR(SEQUENCE(26,,65))
=CHAR(ROW(65:90))

To generate English alphabets a...z

=CHAR(SEQUENCE(26,,97))
=CHAR(ROW(97:122))

To generate English alphabets in a row

=CHAR(SEQUENCE(,26,65))
=CHAR(SEQUENCE(,26,97))
=TRANSPOSE(CHAR(ROW(65:90)))

Related Tutorials

Frequently Asked Questions for Microsoft Excel

Go to View β†’ Freeze Panes to keep a row or column visible while scrolling.

Select data β†’ Click Insert β†’ Chart β†’ Choose a chart type (bar, line, pie, etc.).

=IF(A1>10, "High", "Low") returns "High" if A1 is greater than 10; otherwise, it returns "Low".

Relative (A1): Changes when copied.

Absolute ($A$1): Remains fixed when copied.

Select data β†’ Click Insert β†’ PivotTable β†’ Choose where to place it.

VLOOKUP: Searches vertically in columns.

HLOOKUP: Searches horizontally in rows.

VLOOKUP only searches left to right.
INDEX-MATCH is more flexible and allows searches in any direction.

Click File β†’ Save As, choose a location, enter a filename, and select a format (e.g., .xlsx, .csv).

Select column β†’ Click Data β†’ Text to Columns β†’ Choose delimiter (e.g., comma, space).

Use =SUM(A1:A5) to add values in the range A1 to A5.

Use =COUNTIF(A1:A10, ">50") to count numbers greater than 50 in A1:A10.

Select data β†’ Click Data β†’ Remove Duplicates.

Count numbers: =COUNT(A1:A10)

Count non-empty cells: =COUNTA(A1:A10)

Select cells β†’ Click Conditional Formatting in the Home tab β†’ Choose a rule (e.g., highlight values greater than 50).

#DIV/0! β†’ Division by zero error.
#VALUE! β†’ Invalid data type in formula.
#REF! β†’ Cell reference is missing or deleted.

Click the Pivot Table β†’ Click Refresh under the PivotTable Analyze tab.

Select a cell β†’ Data β†’ Data Validation β†’ Set rules (e.g., allow only numbers or dropdown lists).

Ctrl + C β†’ Copy
Ctrl + V β†’ Paste
Ctrl + Z β†’ Undo
Ctrl + Shift + L β†’ Apply/Remove filter
Ctrl + T β†’ Convert data to a table

Click Review β†’ Protect Sheet, set a password, and select allowed actions.

Excel is a spreadsheet software used for data analysis, calculations, graphing, and automation.

Check for typos in the formula.
Ensure cells referenced contain valid data.
Remove extra spaces in text values.

It searches for a value in the first column of a range and returns a value from another column.

Example: =VLOOKUP(101, A2:C10, 2, FALSE) looks up 101 in column A and returns the corresponding value from column 2.

Use =A1 & " " & B1 or =CONCATENATE(A1, " ", B1).

line

Copyrights © 2024 letsupdateskills All rights reserved