Excel sheet columns numbers

Skip to content

How to Get a Column Number in Excel: Easy Tutorial (2023)

How to Get a Column Number in Excel: Easy Tutorial (2023)

An Excel sheet is two-dimensional – it has rows and columns. By default, row headers in Excel are numbers, and column headers are alphabets.

As the data in your Excel sheet starts to grow in width, the number of columns grows. And this might make it difficult for you to track down a column by its number.

The article below explains different methods of how you can get column numbers in Excel. Also, it focuses on how column numbers might help you in your Excel jobs.

So stay tuned till the end! 😀

Practice the examples shown in the article below by downloading the sample workbook here.

How to get column number with the COLUMN function

If you have never before heard of the COLUMN function, it’s alright. Most Excel users have not.

The COLUMN function of Excel is designed to return the number of a column in Excel.

To find the column numbers for different columns in Excel, see the example below.

Column numbers in Excel

1. Write the COLUMN formula.

=COLUMN()

And this is it!

The COLUMN function has just one argument – the reference argument. Interestingly, this argument is also optional.

If omitted, Excel deems it equal to the Cell reference where the formula is written.

The column number

We had omitted the argument, so Excel set it equal to Cell B2. Column B comes second in the sequence, so Excel returned ‘2’ as the Column number.

Let’s see this the other way around.

2. Set the reference argument to AAX10.

Column argument set to AAX10
The Excel column number

This time Excel returns column number 726. This means Column AAX is the 726th Column of Excel.

How many columns are there in an Excel Sheet?

The last column of an Excel worksheet is Column XFD. So how many columns are there in a single worksheet?

Let’s do it quickly!

  1. Press Ctrl + the right arrow button ➡️ to fast forward to the last column of Excel.
  2. Write the Column formula.

=COLUMN()

Column number of Column XFD

16384 Excel Columns to each worksheet.

Let’s double-check the same from Google! 😆

Number of Excel columns

Examples of uses for the COLUMN function

Why would anyone want to use the COLUMN function? The examples below tell why.

Example 1:

The image below shows the grades of a few students (to the left).

Grades of students

To the right side, we want to fetch out the grades for Henry. Easy solution = VLOOKUP.

1. Write the VLOOKUP function as follows.

= VLOOKUP (E1,

referring to the lookup value

The lookup_value is referred to as Cell E1 because it contains the name of the student to look the result for.

2. Refer to the table array where the lookup and the return values are.

= VLOOKUP (E1, A1:B4,

Referring to the table array

3. For the col_index num argument, nest in the COLUMN function as follows:

= VLOOKUP (F1, A1:B4, COLUMN(B1))

The col_index num argument refers to the column from where the value is to be returned.

And this has to be the number of the column starting from the first column of the table_array.

Nesting the COLUMN function

We want the Grades of Henry to be returned. Grades are listed in column B, so we have referred to Cell B1 (any cell from Column B).

Excel gives the value

Instead of manually counting the columns, let the COLUMN function do the job.

The VLOOKUP function needs the column number starting from the table array. If the table array starts from any column other than the first column, the above function might not work.

Kasper Langmann, Microsoft Office Specialist

For example, what if the table array above started from Column B and not A?

Table array positioning

1. Write the VLOOKUP function as above, and it’d fail to function.

=VLOOKUP (G2, B1:C4, (COLUMN (C1))

It will take the col_index num argument as 3 (Column number of Column C).

Whereas, our table range has only two columns.

Table array positioning

2. Deal with such a situation by changing the COLUMN function as follows.

= COLUMN(C1) – COLUMN(A1)

Subtract the number of the column before the table array (Column A) from the return value column (Column C).

3. Rewrite the VLOOKUP function as below.

= VLOOKUP (G1, B1:C4, COLUMN(C1) – COLUMN(A1))

Here are the results!

Excel finds the grades

Example 2:

The COLUMN function is not only meant to find the number of a single column. You can also use it to find the number of multiple columns at once.

The data below shows the monthly utility bill of a household.

Monthly utility bill of a household.

To find the accumulated utility bill for each month, let’s apply the COLUMN function.

1. Write the COLUMN function as follows.

=COLUMN(A2:F2)

The array column functions

The range A2:F2 tells the number of months for which we need the accumulated bill.

Column function returns an array of column numbers

2. Multiply it with the particular cell of the monthly bill.

= H3 * COLUMN(A2:F2)

The cell reference is set to H3 as it contains the monthly bill.

Monthly utility bill of a household.
Excel Column function returns Monthly accumulated bills

It only takes a single click for Excel to compute the bills for all the months.

When the reference argument of the column function is defined as a range, the output is an array.

Kasper Langmann, Microsoft Office Specialist

Caution! The SPILL Error:

If the cells of the array are not vacant before the array function operates, Excel gives the #SPILL! Error.

The #SPILL! error

Show column number instead of letter

Only if Excel labeled both the rows and columns with numbers and not alphabets – things would have been much easier!

If you think like that, let’s do it for you.

To change the column letter to numbers in Excel, continue reading.

1. Go to File > Options

2. This opens up the Excel options dialog box.

Excel Options dialog box

3. Go to Formulas.

4. Under the tab, ‘Working with Formulas’, check the box R1C1 Reference Style.

R1C1 (row number and column number) Style reference

And swish! Magic. The reference style of columns has changed. 😉

Excel Column letter changed to column number

Your Excel worksheet looks all new with a new reference style! Both columns and rows are labeled by numbers.

The R1C1 style reference indicates the Row number and Column number. Accordingly, the cell references will automatically change.

For example, the traditional Cell reference C5 has now become R5C3 (Row number 5 and Column number 3).

Cell reference under R1C1 reference style

This way, you can easily track down the number of columns.

That’s it – Now what?

By now, we have learned to find the column number in Excel through the COLUMN formula, to nest the COLUMN formula in VLOOKUP, and also to change the Column reference style in Excel.

But that’s all about basic Excel. To become an Excel pro you must master the VLOOKUP, SUMIF, and IF functions.

Where can you learn them? Click here to sign up for my free 30-minute email course that will help you master these functions (and more!).

Other relevant resources:

Finding the column number for a specific column or a group of columns can simplify your Excel jobs.

We suggest you also take a quick look into some shortcuts for adding, moving, splitting, clustering, and comparing columns. Once you have learned these shortcuts and tips, you’ll feel no less than an Excel whizz.

Kasper Langmann2023-01-19T12:23:31+00:00

Page load link

Leetcode Daily — August 10, 2020

Excel Sheet Column Number

Link to Leetcode Question

Lately I’ve been grinding Leetcode and decided to record some of my thoughts on this blog. This is both to help me look back on what I’ve worked on as well as help others see how one might think about the problems.

However, since many people post their own solutions in the discussions section of Leetcode, I won’t necessarily be posting the optimal solution.

Question

(Copy Pasted From Leetcode)

Given a column title as appear in an Excel sheet, return its corresponding column number.

For example:

    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28 
    ...

Example 1:

Example 2:

Example 3:

Constraints:

  • 1 <= s.length <= 7
  • s consists only of uppercase English letters.
  • s is between «A» and «FXSHRXW».

My Approach(es)

I won’t go over all the code for all attempts but I will explain my approach(es) qualitatively.

Attempt 1 — Treat the string as a base 26 number

(Submission — Accepted)

After trying out some examples by hand, I realized that this column naming system is basically a base 26 number. The notable difference is that instead of having a zero digit, we start at 1 with A and end at 26 with Z. Then, 27 resets to AA, which is:

 27 = 1*26 + 1*1 
 27 = A*(26^1) + A*(26^0)

Similarly, ZY, which is 701, can be broken down as:

 701 = 26*26 + 25*1 
 701 = Z*(26^1) + Y*(26^0)

Even without the zero digit, we can be fairly confident in our conversion system. The numbers start counting at 26 to the zeroth power, just like how other number bases start at the zeroth power.

With this we can write our Javascript code, which starts at the right side of the string and starts iterating the powers of 26. I used a dictionary to convert the individual letters to numbers.

Submitted Code:

var titleToNumber = function(s) {
    // s is a string, but basically converts to a number in base 26 
    // also instead of zero we have 26 
    const dict = {
        A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8, I: 9, J: 10, K: 11, L: 12, M: 13, N: 14,
        O: 15, P: 16, Q: 17, R: 18, S: 19, T: 20, U: 21, V: 22, W: 23, X: 24, Y: 25, Z: 26
    }
    let number = 0;
    let power = 0;
    for (let i = s.length-1; i >= 0; i--) {
        number += Math.pow(26, power)*dict[s[i]];
        power ++;
    }
    return number;
};

Attempt 1A — Still Treating the string as a base 26 number

(Submission — Accepted)

I just wanted to try writing this but reading the string’s digits from left to right instead of right to left. Instead of adding the correct power of 26, this iterative method takes the previous number and multiplies all of it by 26 (because it’s all numbers from left to right so far), and then adds the specific digit.

Submitted Code:

var titleToNumber = function(s) {
    // s is a string, but basically converts to a number in base 26 
    // also instead of zero we have 26 
    const dict = {
        A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8, I: 9, J: 10, K: 11, L: 12, M: 13, N: 14,
        O: 15, P: 16, Q: 17, R: 18, S: 19, T: 20, U: 21, V: 22, W: 23, X: 24, Y: 25, Z: 26
    }
    let number = 0;

    for (let i = 0; i < s.length; i++) {
        number = number*26 + dict[s[i]];
    }
    return number;
};

Discussion and Conclusions

There is not much I want to say about this question. Once the naming/numbering system is understood, the conversion can be done as a numerical base 26 conversion, with the added step of parsing the string. Even though I’m sure there are ways to optimize the code, I believe this is sufficient understanding of the problem.

The time complexity is O(n) for n equal to the length of string s, but the length of s is constrained to be less than or equal to 7.

Difficulty Level Easy
Frequently asked in Microsoft
algorithms coding Interview interviewprep LeetCode LeetCodeSolutions Math Number SystemViews 1323

Problem Statement

In this problem we are given a column title as appear in an Excel sheet, we have to return the column number that corresponds to that column title in Excel as shown below.

Excel Sheet Column Number Leetcode Solution

Example

#1

"AB"
28

#2

"ZY"
701

Approach

To find column number for a particular column title we can think of it like converting from one number system to another number system.
Like in decimal number we have characters 0 to 9 to represent any number in decimal. Similarly in column title the characters are from A to Z to represent any number. There are total of 26 symbols for each place, therefore we can think of a number in a system whose base is 26.

Now question becomes very simple. Like we convert any binary or hexa-decimal number to its decimal form, we have to convert this title string into a decimal number.

For example, if we want to find the decimal value of string “1337”, we can iteratively find the number by traversing the string from left to right as follows:
‘1’ = 1
’13’ = (1 x 10) + 3 = 13
‘133’ = (13 x 10) + 3 = 133
‘1337’ = (133 x 10) + 7 = 1337

Now in this problem as we are dealing with base-26 number system. Based on the same idea, we can just replace 10s with 26s and convert alphabets to numbers.

For a title “LEET”:

L = 12
E = (12 x 26) + 5 = 317
E = (317 x 26) + 5 = 8247
T = (8247 x 26) + 20 = 214442

Implementation

C++ Program for Excel Sheet Column Number Leetcode Solution

#include <bits/stdc++.h>
using namespace std;

int titleToNumber(string s)
{        
        int ans=0;        
        for(auto c:s)
        {
          ans= ans*26 + (c-'A'+1);    
        }
    
        return ans;
}

int main() 
{

   cout<<titleToNumber("AB") <<endl;

   return 0; 
}
28

Java Program for Excel Sheet Column Number Leetcode Solution

class Rextester{
    
  public static int titleToNumber(String s) 
    {             
        int ans=0;
        for(char c:s.toCharArray())
        {
          ans= ans*26 + (c-'A'+1);    
        }
        
        return ans;
    }
    
  public static void main(String args[])
    {
       	
    System.out.println( titleToNumber("AB") ) ;
    }
}
28

Complexity Analysis for Excel Sheet Column Number Leetcode Solution

Time Complexity

O(N) : Where N is the total number of characters in the input string. We iterated once along the characters, hence time complexity will be O(N).

Space Complexity 

O(1) : We just used one integer variable for storing the result.

My column headings are labeled with numbers instead of letters

  1. On the Excel menu, click Preferences.
  2. Under Authoring, click General .
  3. Clear the Use R1C1 reference style check box. The column headings now show A, B, and C, instead of 1, 2, 3, and so on.

Contents

  • 1 How do you change Excel to Numbers?
  • 2 How do I show column numbers in Excel?
  • 3 How do I convert text to values in Excel?
  • 4 How do I convert a column of numbers to column names in Excel?
  • 5 How do I change the number format in Excel?
  • 6 Why does Excel have numbers for columns?
  • 7 How do I show columns and row numbers in Excel?
  • 8 How do I get columns and row numbers in Excel?
  • 9 How do I get row numbers in Excel?
  • 10 How do I format numbers in Excel?
  • 11 What are the different ways in formatting numbers?
  • 12 How do I change the column title in Excel?
  • 13 How do I change rows and column names in Excel?
  • 14 How do I change Excel columns from numbers to alphabets?
  • 15 How do I get rid of column 1 headers in Excel?
  • 16 How do I change the row numbers in Excel?
  • 17 What is an Xlookup in Excel?
  • 18 Why can’t I see row numbers in Excel?
  • 19 How do I add a numbered list in Excel?
  • 20 How do I automatically number in sheets?

Change numbers with text format to number format in Excel for the…

  1. Select the cells that have the data you want to reformat.
  2. Click Number Format > Number. Tip: You can tell a number is formatted as text if it’s left-aligned in a cell.

How do I show column numbers in Excel?

Show column number

  1. Click File tab > Options.
  2. In the Excel Options dialog box, select Formulas and check R1C1 reference style.
  3. Click OK.

How do I convert text to values in Excel?

Use the Format Cells option to convert number to text in Excel

  1. Select the range with the numeric values you want to format as text.
  2. Right click on them and pick the Format Cells… option from the menu list. Tip. You can display the Format Cells…
  3. On the Format Cells window select Text under the Number tab and click OK.

How do I convert a column of numbers to column names in Excel?

To convert a column number to an Excel column letter (e.g. A, B, C, etc.) you can use a formula based on the ADDRESS and SUBSTITUTE functions. With this information, ADDRESS returns the text “A1”.

How do I change the number format in Excel?

You can use the Format Cells dialog to find the other available format codes:

  1. Press Ctrl+1 ( +1 on the Mac) to bring up the Format Cells dialog.
  2. Select the format you want from the Number tab.
  3. Select the Custom option,
  4. The format code you want is now shown in the Type box.

Why does Excel have numbers for columns?

Cause: The default cell reference style (A1), which refers to columns as letters and refers to rows as numbers, was changed. Solution: Clear the R1C1 reference style selection in Excel preferences. On the Excel menu, click Preferences.The column headings now show A, B, and C, instead of 1, 2, 3, and so on.

How do I show columns and row numbers in Excel?

On the Ribbon, click the Page Layout tab. In the Sheet Options group, under Headings, select the Print check box. , and then under Print, select the Row and column headings check box .

How do I get columns and row numbers in Excel?

It is quite easy to figure out the row number or column number if you know a cell’s address. If the cell address is NK60, it shows the row number is 60; and you can get the column with the formula of =Column(NK60). Of course you can get the row number with formula of =Row(NK60).

How do I get row numbers in Excel?

Use the ROW function to number rows

  1. In the first cell of the range that you want to number, type =ROW(A1). The ROW function returns the number of the row that you reference. For example, =ROW(A1) returns the number 1.
  2. Drag the fill handle. across the range that you want to fill.

How do I format numbers in Excel?

Formatting the Numbers in an Excel Text String

  1. Right-click any cell and select Format Cell.
  2. On the Number format tab, select the formatting you need.
  3. Select Custom from the Category list on the left of the Number Format dialog box.
  4. Copy the syntax found in the Type input box.

What are the different ways in formatting numbers?

How to change number formats. You can select standard number formats (General, Number, Currency, Accounting, Short Date, Long Date, Time, Percentage, Fraction, Scientific, Text) on the home tab of the ribbon using the Number Format menu. Note: As you enter data, Excel will sometimes change number formats automatically.

How do I change the column title in Excel?

Select a column, and then select Transform > Rename. You can also double-click the column header. Enter the new name.

How do I change rows and column names in Excel?

Rename columns and rows in a worksheet

  1. Click the row or column header you want to rename.
  2. Edit the column or row name between the last set of quotation marks. In the example above, you would overwrite the column name Gold Collection.
  3. Press Enter. The header updates.

How do I change Excel columns from numbers to alphabets?

To change the column headings to letters, select the File tab in the toolbar at the top of the screen and then click on Options at the bottom of the menu. When the Excel Options window appears, click on the Formulas option on the left. Then uncheck the option called “R1C1 reference style” and click on the OK button.

How do I get rid of column 1 headers in Excel?

Go to Table Tools > Design on the Ribbon. In the Table Style Options group, select the Header Row check box to hide or display the table headers. If you rename the header rows and then turn off the header row, the original values you input will be retained if you turn the header row back on.

How do I change the row numbers in Excel?

Here are the steps to use Fill Series to number rows in Excel:

  1. Enter 1 in cell A2.
  2. Go to the Home tab.
  3. In the Editing Group, click on the Fill drop-down.
  4. From the drop-down, select ‘Series..’.
  5. In the ‘Series’ dialog box, select ‘Columns’ in the ‘Series in’ options.
  6. Specify the Stop value.
  7. Click OK.

What is an Xlookup in Excel?

Use the XLOOKUP function to find things in a table or range by row.With XLOOKUP, you can look in one column for a search term, and return a result from the same row in another column, regardless of which side the return column is on.

Why can’t I see row numbers in Excel?

In order to show (or hide) the row and column numbers and letters go to the View ribbon. Set the check mark at “Headings”. That’s it!

How do I add a numbered list in Excel?

Click the Home tab in the Ribbon. Click the Bullets and Numbering option in the new group you created. The new group is on the far right side of the Home tab. In the Bullets and Numbering window, select the type of bulleted or numbered list you want to add to the text box and click OK.

How do I automatically number in sheets?

Use autofill to complete a series

  1. On your computer, open a spreadsheet in Google Sheets.
  2. In a column or row, enter text, numbers, or dates in at least two cells next to each other.
  3. Highlight the cells. You’ll see a small blue box in the lower right corner.
  4. Drag the blue box any number of cells down or across.

Содержание

  1. COLUMN Function Examples – Excel & Google Sheets
  2. COLUMN Function Overview
  3. COLUMN function Syntax and inputs:
  4. COLUMN Function – Single Cell
  5. COLUMN Function with no Reference
  6. COLUMN Function with a Range
  7. Excel 2019 or older
  8. Excel 365
  9. COLUMN Function in Google Sheets
  10. Additional Notes
  11. Русские Блоги
  12. Excel Sheet Column Number
  13. 171. Excel Sheet Column Number
  14. Интеллектуальная рекомендация
  15. Poj2796 чувствую себя хорошим одиноким стеком
  16. Начало работы с spring-mvc (1): примеры начала работы
  17. От Дао к Джейн — Душа архитектуры RISC-V (Часть 2)
  18. последовательность очереди
  19. N Вопрос королевы (рекурсивный + обратно) Реализация C ++
  20. Вам также может понравиться
  21. Bluetooth 4.0 BLE Программирование Вопросы, связанные с вопросами решения (воспроизводится)
  22. Напишите скрипт оболочки в Linux и выполните инструкцию Python
  23. Selenium2 испытательный фреймворк идея-03
  24. Командный режим
  25. Одно -гликовая микрокомпьютер (STM32).
  26. COLUMN function
  27. Syntax
  28. How to number columns in Excel and convert column letter to number
  29. How to return column number in Excel
  30. How to convert column letter to number (non-volatile formula)
  31. Change column letter to number using a custom function
  32. Return column number of a specific cell
  33. Get column letter of the current cell
  34. How to show column numbers in Excel
  35. How to number columns in Excel

COLUMN Function Examples – Excel & Google Sheets

Download the example workbook

This Tutorial demonstrates how to use the Excel COLUMN Function in Excel to look up the column number.

COLUMN Function Overview

The COLUMN Function Returns the column number of a cell reference.

To use the COLUMN Excel Worksheet Function, select a cell and type:

(Notice how the formula inputs appear)

COLUMN function Syntax and inputs:

reference – Cell reference that you want to determine the column # of.

COLUMN Function – Single Cell

The COLUMN Function returns the column number of the given cell reference.

COLUMN Function with no Reference

If no cell reference is provided, the COLUMN Function will return the column number where the formula is entered

COLUMN Function with a Range

You can also input entire ranges of cells into the COLUMN Function. When doing so, the COLUMN Function behaves differently in Excel 2019 (or earlier) vs. Excel 365 or newer version of Excel.

Excel 2019 or older

In previous versions of Excel, the COLUMN Function returns an array containing the column values of all the cells in the range, but only displays the first result in the cell.

If you click the cell containing the formula and press F9, all the results are displayed in curly brackets as an array.

Excel 365

However, Excel 365 (and newer versions of Excel, presumably) comes with a spill range feature. Here, the COLUMN Function will return the columns of all cells in the range, “spilled” into the next cells.

COLUMN Function in Google Sheets

The COLUMN Function works exactly the same in Google Sheets as in Excel:

Additional Notes

Use the COLUMN Function to return the column number of a cell reference. What if you want the column letter of a cell reference? Use this complicated formula instead:

This formula calculates the column number with the COLUMN Function and calculates the address of a cell in row 1 of that column using the ADDRESS Function. Then it uses the SUBSTITUTE Function to remove the row number (1), so all that remains is the column letter.

Источник

Русские Блоги

Excel Sheet Column Number

171. Excel Sheet Column Number

Given a column title as appear in an Excel sheet, return its corresponding column number.

Example 1:

Example 2:

Example 3:

Интеллектуальная рекомендация

Poj2796 чувствую себя хорошим одиноким стеком

http://poj.org/problem?id=2796 Значение: требует поиска диапазона значения, интервальное значение, определенное как минимум интервала интервала и умножения. Практика: непосредственно нашел интервалы с.

Начало работы с spring-mvc (1): примеры начала работы

введение 1.MVC :Model-View-Control РамообразнойC Основная работа, которую необходимо выполнить на уровне: инкапсуляцияweb Запрос является объектом данных, вызывает уровень бизнес-логики для обработки .

От Дао к Джейн — Душа архитектуры RISC-V (Часть 2)

Эта статья входит в серию статей «Проектирование ЦП RISC-V» и «Разработка встроенного программного обеспечения RISC-V». Примечание. Эта статья представляет собой отрывок из пер.

последовательность очереди

При написании кода вам необходимо добавить заголовочный файл «очередь», за которым следует #include «алгоритм». с использованием пространства имен std; также есть q, pop () при.

N Вопрос королевы (рекурсивный + обратно) Реализация C ++

N Вопросы королевы (рекурсивный + назад N Queens, выпущенные технологией функции имитации C ++: Решить класс проблем: Основная функция: результат Результаты здесь опущены, и существует 92 консенсус бе.

Вам также может понравиться

Bluetooth 4.0 BLE Программирование Вопросы, связанные с вопросами решения (воспроизводится)

Q: Что такое связь Bluetooth? A: Оригинальный дизайн связи Bluetooth заключается в том, чтобы облегчить низкую стоимость между мобильными телефонами (мобильными телефонами) и аксессуарами, беспроводны.

Напишите скрипт оболочки в Linux и выполните инструкцию Python

Статус -кво спроса: вам нужно написать сценарий, и некоторые вызовы сценария Python инкапсулируются в скрипте Пример Описание: Напишите скрипт оболочки на платформе Linux, а затем регулярно вызовите. .

Selenium2 испытательный фреймворк идея-03

Фактически, в процессе нашего тестирования мы обнаружим, что существует множество проблем с данными, которые необходимо решить. Например, верны ли данные, возвращаемые на странице? Данные полны? Нам в.

Командный режим

Определения Командный режим инкапсулирует запросы в объекты, чтобы можно было использовать разные запросы, очереди или журналы. Оцифровка других объектов. Командный режим также поддерживает отмену опе.

Одно -гликовая микрокомпьютер (STM32).

Одно -гликовая микрокомпьютер (STM32). Эта статья представляет собой запись опыта личного обучения, что удобно для будущего обзора, а также предоставляет удобство для других друзей. У меня ограниченна.

Источник

COLUMN function

The COLUMN function returns the column number of the given cell reference. For example, the formula = COLUMN( D10) returns 4, because column D is the fourth column.

Syntax

The COLUMN function syntax has the following argument:

reference Optional. The cell or range of cells for which you want to return the column number.

If the reference argument is omitted or refers to a range of cells, and if the COLUMN function is entered as a horizontal array formula, the COLUMN function returns the column numbers of reference as a horizontal array.

If you have a current version of Microsoft 365, then you can simply enter the formula in the top-left-cell of the output range, then press ENTER to confirm the formula as a dynamic array formula. Otherwise, the formula must be entered as a legacy array formula by first selecting the output range, entering the formula in the top-left-cell of the output range, and then pressing CTRL+SHIFT+ENTER to confirm it. Excel inserts curly brackets at the beginning and end of the formula for you. For more information on array formulas, see Guidelines and examples of array formulas.

If the reference argument is a range of cells, and if the COLUMN function is not entered as a horizontal array formula, the COLUMN function returns the number of the leftmost column.

If the reference argument is omitted, it is assumed to be the reference of the cell in which the COLUMN function appears.

The reference argument cannot refer to multiple areas.

Источник

How to number columns in Excel and convert column letter to number

by Svetlana Cheusheva, updated on March 9, 2023

The tutorial talks about how to return a column number in Excel using formulas and how to number columns automatically.

Last week, we discussed the most effective formulas to change column number to alphabet. If you have an opposite task to perform, below are the best techniques to convert a column name to number.

How to return column number in Excel

To convert a column letter to column number in Excel, you can use this generic formula:

For example, to get the number of column F, the formula is:

And here’s how you can identify column numbers by letters input in predefined cells (A2 through A7 in our case):

Enter the above formula in B2, drag it down to the other cells in the column, and you will get this result:

How this formula works:

First, you construct a text string representing a cell reference. For this, you concatenate a letter and number 1. Then, you hand off the string to the INDIRECT function to convert it into an actual Excel reference. Finally, you pass the reference to the COLUMN function to get the column number.

How to convert column letter to number (non-volatile formula)

Being a volatile function, INDIRECT can significantly slow down your Excel if used broadly in a workbook. To avoid this, you can identify the column number using a slightly more complex non-volatile alternative:

This works perfectly in dynamic array Excel (365 and 2021). In older version, you need to enter it as an array formula (Ctrl + Shift + Enter) to get it to work.

=MATCH(A2&»1″, ADDRESS(1, COLUMN($1:$1), 4), 0)

Or you can use this non-array formula in all Excel versions:

=MATCH(A2&»1″, INDEX(ADDRESS(1, INDEX(COLUMN($1:$1), ), 4), ), 0)

How this formula works:

First off, you concatenate the letter in A2 and the row number «1» to construct a standard «A1» style reference. In this example, we have letter «A» in A2, so the resulting string is «A1».

Next, you get an array of strings representing all cell addresses in the first row, from «A1» to «XFD1». For this, you use the COLUMN($1:$1) function, which generates a sequence of column numbers, and pass that array to the column_num argument of the ADDRESS function:

Given that row_num (1st argument) is set to 1 and abs_num (3rd argument) is set to 4 (meaning you want a relative reference), the ADDRESS function delivers this array:

Finally, you build a MATCH formula that searches for the concatenated string in the above array and returns the position of the found value, which corresponds to the column number you are looking for:

Change column letter to number using a custom function

«Simplicity is the ultimate sophistication,» stated the great artist and scientist Leonardo da Vinci. To get a column number from a letter in an easy way, you can create your own custom function.

Fully in line with the above principle, the function’s code is as simple as it can possibly be:

Insert the code in your VBA editor as explained here, and your new function named ColumnNumber is ready for use.

The function requires just one argument, col_letter, which is the column letter to be converted into a number:

Your real formula can be as follows:

If you compare the results returned by our custom function and Excel’s native ones, you will make sure they are exactly the same:

Return column number of a specific cell

To get a column number of a particular cell, simply use the COLUMN function:

For instance, to identify the column number of cell B3, the formula is:

Obviously, the result is 2.

Get column letter of the current cell

To find out a column number of the current cell, use the COLUMN() function with an empty argument, so it refers to the cell where the formula is:

=COLUMN()

How to show column numbers in Excel

By default, Excel uses the A1 reference style and labels column headings with letters and rows with numbers. To get columns labeled with numbers, change the default reference style from A1 to R1C1. Here’s how:

  1. In your Excel, click File >Options.
  2. In the Excel Options dialog box, select Formulas in the left pane.
  3. Under Working with formulas, check the R1C1 reference style box, and click OK.

The column labels will immediately change from letters to numbers:

Please note that selecting this option will not only change column labels — cell addresses will also change from A1 to R1C1 references, where R means «row» and C means «column». For example, R1C1 refers to the cell in row 1 column 1, which corresponds to the A1 reference. R2C3 refers to the cell in row 2 column 3, which corresponds to the C2 reference.

In existing formulas, cell references will update automatically, while in new formulas you will have to use the R1C1 reference style.

Tip. To revert back to A1 style, uncheck the R1C1 reference style check box in Excel Options.

How to number columns in Excel

If you are not used to the R1C1 reference style and want to keep A1 references in your formulas, then you can insert numbers in the first row of our worksheet, so you have both — column letters and numbers. This can be easily done with the help of the Auto Fill feature.

Here are the detailed steps:

  1. In A1, type number 1.
  2. In B1, type number 2.
  3. Select cells A1 and B1.
  4. Hover the cursor over a small square in the lower right corner of cell B1, which is called the Fill handle. As you do this, the cursor will change to a thick black cross.
  5. Drag the fill handle to the right up to the column you need.

As a result, you will retain the column labels as letters, and underneath the letters you will have the column numbers.

Tip. To keep the columns numbers in view while scrolling to the below areas of the worksheet, you can freeze top row.

That’s how to return column numbers in Excel. I thank you for reading and look forward to seeing you on our blog next week!

Источник

Понравилась статья? Поделить с друзьями:
  • Excel sheet clear all
  • Excel search for value in cell
  • Excel sheet cells vba excel
  • Excel scroll lock как включить
  • Excel sheet cells value