# COLUMNS formula generator

> Describe what you need and get a COLUMNS formula for Excel and Google Sheets, run on real data before you copy it. Plus 3 tested COLUMNS examples.

Source: https://spreadsheetpractice.com/tools/formula-generator/columns · Updated October 29, 2026 · Formulas and results on this page were run by the Spreadsheet Practice formula engine on November 20, 2026

COLUMNS counts how many columns a range or array has, whether or not the cells contain anything.

Describe the task at [COLUMNS formula generator](https://spreadsheetpractice.com/tools/formula-generator/columns) and get a COLUMNS formula for Excel and Google Sheets, tested on real data.

## Tested COLUMNS examples

### Fix the #REF! error in VLOOKUP

`=VLOOKUP(G1,A2:D9,4,FALSE)`

Excel. Result on the sample sheet: 210. [See it and try it](https://spreadsheetpractice.com/formulas/vlookup-ref-error)

### Calculate attendance percentage

`=COUNTIF(B2:G2,"P")/COUNTA(B2:G2)`

Excel. Result on the sample sheet: 6 rows (H2:H7). [See it and try it](https://spreadsheetpractice.com/formulas/attendance-percentage)

### Split text into columns with a formula

`=TEXTSPLIT(A2,", ")`

Excel. Result on the sample sheet: 5 rows (B2:B6). [See it and try it](https://spreadsheetpractice.com/formulas/split-text-into-columns-with-a-formula)

## Questions

### What does the COLUMNS formula generator do?

You describe the task in plain English, and it writes the formula, using COLUMNS where that's the right tool, for your table or a sample one. The formula is run in our engine in Excel and Google Sheets mode before you see it, so you get its result, not just a guess.

### What does COLUMNS do?

COLUMNS counts how many columns a range or array has, whether or not the cells contain anything.

### Can I learn to write COLUMNS formulas myself?

Yes. Each example below opens a page where you try the formula in a live grid and it's checked as you go, and the COLUMNS function page has a practice exercise.

---

Spreadsheet Practice (https://spreadsheetpractice.com) teaches spreadsheet formulas by practice: every exercise is graded in a live grid and re-checked on changed data.
