Skip to content
Free Excel Tutorials
  • Home
  • Excel For Beginners
  • Excel Intermediate
  • Advanced Excel For Experts

Data Analysis

  • How To Remove Duplicates In Excel Column Or Row?
  • Add Outline to Data in Excel
  • Get column index in Excel Table
  • Managing Conditional Formatting Rules in Excel
  • Excel Line Chart

References

  • How to get first row number in range in Excel
  • How to get address of last cell in range in Excel
  • How to use Excel COLUMN Function
  • Two-way lookup with VLOOKUP in Excel
  • Get nth match with INDEX / MATCH in Excel

Data Validations

  • Excel Data validation date in next 30 days
  • Excel Data validation no punctuation
  • Excel Data validation must contain specific text
  • Excel Data validation specific characters only
  • Excel Data validation require unique number

How to get relative column numbers in a range in Excel

by

This tutorial shows how to get a full set of relative column numbers in a range using an array formula based on the COLUMN function.

Formula

{=COLUMN(range)-COLUMN(range.firstcell)+1}


On the worksheet, this must be entered as multi-cell array formula using Control + Shift + Enter

Worked Example:   Check if multiple cells have same value in Excel

This is a robust formula that will continue to generate relative numbers even when columns are inserted in front of the range.

Explanation

In the example shown, the array formula in B4:H4 is:

{=COLUMN(B4:H4)-COLUMN(B4)+1}

How this formula works

The first COLUMN function generates an array of 7 numbers like this:

Worked Example:   Hide and Unhide Columns or Rows in Excel

{2,3,4,5,6,7,8}

The second COLUMN function generates an array with just one item like this:

{2}

which is then subtracted from the first array to yield:

{0,1,2,3,4,5,6}

Finally, 1 is added to get:

Worked Example:   Dynamic Named Range in Excel

{1,2,3,4,5,6,7}

With a named range

You can adapt this formula to use with a named range. For example, in the above example, if you created a named range “data” for B4:H4, you can use this formula to generate column numbers:

{=COLUMN(data)-COLUMN(INDEX(data,1,1))+1}

Post navigation

Previous Post:

How to generate random date between two dates in Excel

Next Post:

Popularly Used Excel Functions and their examples

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Learn Basic Excel

Ribbon
Workbook
Worksheets
Format Cells
Find & Select
Sort & Filter
Templates
Print
Share
Protect
Keyboard Shortcuts

Categories

  • Charts
  • Data Analysis
  • Data Validation
  • Excel Functions
    • Cube Functions
    • Database Functions
    • Date and Time Functions
    • Engineering Functions
    • Financial Functions
    • Information Functions
    • Logical Functions
    • Lookup and Reference Functions
    • Math and Trig Functions
    • Statistical Functions
    • Text Functions
    • Web Functions
  • Excel VBA
  • Excel Video Tutorials
  • Formatting
  • Grouping
  • Others

Logical Functions

  • How to use Excel NOT Function
  • How to use Excel AND Function
  • IFERROR function: Description, Usage, Syntax, Examples and Explanation
  • TRUE function: Description, Usage, Syntax, Examples and Explanation
  • SWITCH function: Description, Usage, Syntax, Examples and Explanation

Date Time

  • How to join date and text together in Excel
  • Calculate series of dates by workdays in Excel
  • Add workdays to date custom weekends in Excel
  • Convert decimal seconds to Excel time
  • Get work hours between dates and times in Excel

Grouping

  • Group times into 3 hour buckets in Excel
  • Group numbers with VLOOKUP in Excel
  • Map text to numbers in Excel
  • Calculate conditional mode with criteria in Excel
  • Group numbers at uneven intervals in Excel

General

  • How to calculate project complete percentage in Excel
  • How to count total columns in range in Excel
  • Basic error trapping example in Excel
  • 44 Practical Excel IF function Examples
  • How to password protect excel sheet?
© 2023 xlsoffice . All Right Reserved. | Teal Smiles | Abbreviations And Their Meaning