Excel column number in range

Range.EntireColumn

Yes! You can use Range.EntireColumn MSDN

dim column : column = 4

dim column_range : set column_range = Sheets(1).Cells(column).EntireColumn

Range(«ColumnName:ColumnName»)

If you were after a specific column, you could create a hard coded column range with the syntax e.g. Range("D:D").

However, I’d use entire column as it provides more flexibility to change that column at a later time.

Worksheet.Columns

Worksheet.Columns provides Range access to a column within a worksheet. MSDN

If you would like access to the first column of the first sheet. You would
call the Columns function on the worksheet.

dim column_range: set column_range = Sheets(1).Columns(1)

The Columns property is also available on any Range MSDN

EntireRow can also be useful if you have a range for a single cell but would like to reach other cells on the row, akin to a LOOKUP

dim id : id = 12345


dim found : set found = Range("A:A").Find(id)

if not found is Nothing then
    'Get the fourth cell from the match
    MsgBox found.EntireRow.Cells(4)
end if

When given a single cell reference, the COLUMN function returns the column number for that reference. However, when given a range that contains multiple columns, the COLUMN function will return an array that contains all column numbers for the range. In the example shown the array looks like this:

{2,3,4}

If you want only the first column number, you can use the MIN function to extract just the first column number, which will be the lowest number in the array.

Simple version

Entered in a single cell, the COLUMN function will display only the first column number, even when it returns an array. This means, in practice, you can often just use the COLUMN function alone:

=COLUMN(rng)

However, inside formulas more complex formulas, it’s sometimes necessary to make sure you are dealing with only one item, and not an array. In that case, you’ll want to use MIN to pull out just the first item.

Date yes Add (Subtract) Days to a Date Concatenate Dates Convert Date to Number Convert Date to Text Month Name to Number Create Date Range from Dates Day Number of Year Month Name from Date First Day of Month Add (Subtract) Weeks to a Date If Functions with Dates Max Date Number of Days Between Dates Number of Days in a Month Number of Weeks Between Dates Number of Years Between Dates Split Date & Time into Separate Cells Countdown Remaining Days Insert Dates Random Date Generator Using Dynamic Ranges — Year to Date Values Add (Subtract) Years to a Date Date Formula Examples Extract Day from Date Get Day Name from Date Count Days Left in Month / Year Count Workdays Left in Month / Year Get Last Day of Month Last Business Day of Month / Year Number of Work / Business Days in Month Weekday Abbreviations Auto Populate Dates Number of Months Between Dates Quarter from a Date Years of Service Change Date Format Compare Dates Time yes Add (Subtract) Hours to Time Add (Subtract) Minutes to Time Add (Subtract) Seconds to Time Add Up time (Total Time) Time Differences Change Time Format Convert Minutes to Hours Convert Time to Decimal Convert Time to Hours Convert Time to Minutes Convert Time to Seconds Military Time Round Time to Nearest 15 Minutes Overtime Calculator Number of Hours Between Times Convert Seconds to Minutes, Hours, or Time Count Hours Worked Time Differences Time Format — Show Minutes Seconds Text yes Add Commas to Cells Get First Word from Text Capitalize First Letter Clean & Format Phone #s Remove Extra Trailing / Leading Spaces Add Spaces to Cell Assign Number Value to Text Combine Cells with Comma Combine First and Last Names Convert Text String to Date Convert Text to Number Extract Text From Cell Get Last Word Remove Unwated Characters Extract Text Before or After Character How to Split Text String by Space, Comma, & More Remove Special Characters Remove First Characters from Left Substitute Multiple Values Switch First & Last Names w/ Commas Remove Specific Text from a Cell Extract Text Between Characters (Ex. Parenthesis) Add Leading Zeros to a Number Remove Line Breaks from Text Remove all Numbers from Text Reverse Text Remove Non-Numeric Characters Remove Last Character(s) From Right Separate First and Last Names Separate Text & Numbers Round yes Round Formulas Round Price to Nearest Dollar or Cent Round to Nearest 10, 100, or 1000 Round to Nearest 5 or .5 Round Percentages Round to Significant Figures Count yes Count Blank and Non-blank Cells Count Cells Between Two Numbers Count Cells not Equal to Count if Cells are in Range Count Times Word Appears in Cell Count Words in Cell Count Specific Characters in Column Count Total Number of Characters in Column Count Cells that Equal one of two Results Count Cells that do not Contain Count Cells that Contain Specific Text Count Unique Values in Range Countif — Multiple Criteria Count Total Number of Cells in Range Count Cells with Any Text Count Total Cells in a Table Lookup yes Two Dimensional VLOOKUP VLOOKUP Simple Example Vlookup — Multiple Matches Case Sensitive Lookup Case Sensitive VLOOKUP Sum if — VLOOKUP Case Sensitive Lookup Case Sensitive VLOOKUP Find Duplicates w/ VLOOKUP or MATCH INDEX MATCH MATCH Lookup — Return Cell Address (Not Value) Lookup Last Value in Column or Row Reverse VLOOKUP (Right to Left) Risk Score Bucket with VLOOKUP Sum with a VLOOKUP Function VLOOKUP & INDIRECT VLOOKUP Concatenate VLOOKUP Contains (Partial Match) 17 Reasons Why Your XLOOKUP is Not Working Double (Nested) XLOOKUP — Dynamic Columns IFERROR (& IFNA) XLOOKUP Lookup Min / Max Value Nested VLOOKUP Top 11 Alternatives to VLOOKUP (Updated 2022!) VLOOKUP – Dynamic Column Reference VLOOKUP – Fix #N/A Error VLOOKUP – Multiple Sheets at Once VLOOKUP & HLOOKUP Combined VLOOKUP & MATCH Combined VLOOKUP Between Worksheets or Spreadsheets VLOOKUP Duplicate Values VLOOKUP Letter Grades VLOOKUP Return Multiple Columns VLOOKUP Returns 0? Return Blank Instead VLOOKUP w/o #N/A Error XLOOKUP Multiple Sheets at Once XLOOKUP Between Worksheets or Spreadsheets XLOOKUP by Date XLOOKUP Duplicate Values XLOOKUP Multiple Criteria XLOOKUP Return Multiple Columns XLOOKUP Returns 0? Return Blank Instead XLOOKUP Text XLOOKUP with IF XLOOKUP With If Statement Misc. yes Sort Multiple Columns Use Cell Value in Formula Percentage Change Between Numbers Percentage Breakdown Rank Values Add Spaces to Cell CAGR Formula Average Time Decimal Part of Number Integer Part of a Number Compare Items in a List Dealing with NA() Errors Get Worksheet Name Wildcard Characters Hyperlink to Current Folder Compound Interest Formula Percentage Increase Create Random Groups Sort with the Small and Large Functions Non-volatile Function Alternatives Decrease a Number by a Percentage Calculate Percent Variance Profit Margin Calculator Convert Column Number to Letter Get Full Address of Named Range Insert File Name Insert Path Latitute / Longitude Functions Replace Negative Values Reverse List Range Convert State Name to Abbreviation Create Dynamic Hyperlinks Custom Sort List with Formula Data Validation — Custom Formulas Dynamic Sheet Reference (INDIRECT) Reference Cell in Another Sheet or Workbook Get Cell Value by Address Get Worksheet Name Increment Cell Reference List Sheet Names List Skipped Numbers in Sequence Return Address of Max Value in Range Search by Keywords Select Every Other (or Every nth) Row Basics yes Cell Reference Basics — A1, R1C1, 3d, etc. Add Up (Sum) Entire Column or Row Into to Dynamic Array Formulas Conversions yes Convert Time Zones Convert Celsius to Fahrenheit Convert Pounds to Kilograms Convert Time to Unix Time Convert Feet to Meters Convert Centimeters to Inches Convert Kilometers to Miles Convert Inches to Feet Convert Date to Julian Format Convert Column Letter to Number Tests yes Test if a Range Contains any Text Test if any Cell in Range is Number Test if a Cell Contains a Specific Value Test if Cell Contains Any Number Test if Cell Contains Specific Number Test if Cell is Number or Text If yes Percentile If Subtotal If Sumproduct If Large If and Small If Median If Concatentate If Max If Rank If TEXTJOIN If Sum yes Sum if — Begins With / Ends With Sum if — Month or Year to Date Sum if — By Year Sum if — Blank / Non-Blank Sum if — Horizontal Sum Count / Sum If — Cell Color INDIRECT Sum Sum If — Across Multiple Sheets Sum If — By Month Sum If — Cells Not Equal To Sum If — Not Blank Sum if — Between Values Sum If — Week Number Sum Text Sum if — By Category or Group Sum if — Cell Contains Specific Text (Wildcards) Sum if — Date Rnage Sum if — Dates Equal Sum if — Day of Week Sum if — Greater Than Sum if — Less Than Average yes Average Non-Zero Values Average If — Not Blank Average — Ignore 0 Average — Ignore Errors Math yes Multiplication Table Cube Roots nth Roots Square Numbers Square Roots Calculations yes Calculate a Ratio Calculate Age KILLLLLLL Calculate Loan Payments GPA Formula Calculate VAT Tax How to Grade Formulas Find yes Find a Number in a Column / Workbook Find Most Frequent Numbers Find Smallest n Values Find nth Occurance of Character in Text Find and Extract Number from String Find Earliest or Latest Date Based on Criteria Find First Cell with Any Value Find Last Row Find Last Row with Data Find Missing Values Find Largest n Values Most Frequent Number Conditional Formatting yes Conditional Format — Dates & Times Conditional Format — Highlight Blank Cells New Functions XLOOKUP Replaces VLOOKUP, HLOOKUP, and INDEX / MATCH Logical yes AND Checks whether all conditions are met. TRUE/FALSE IF If condition is met, do something, if not, do something else. IFERROR If result is an error then do something else. NOT Changes TRUE to FALSE and FALSE to TRUE. OR Checks whether any conditions are met. TRUE/FALSE XOR Checks whether one and only one condition is met. TRUE/FALSE Lookup & Reference yes FALSE The logical value: FALSE. TRUE The logical value: TRUE. ADDRESS Returns a cell address as text. AREAS Returns the number of areas in a reference. CHOOSE Chooses a value from a list based on it’s position number. COLUMN Returns the column number of a cell reference. COLUMNS Returns the number of columns in an array. HLOOKUP Lookup a value in the first row and return a value. HYPERLINK Creates a clickable link. INDEX Returns a value based on it’s column and row numbers. INDIRECT Creates a cell reference from text. LOOKUP Looks up values either horizontally or vertically. MATCH Searches for a value in a list and returns its position. OFFSET Creates a reference offset from a starting point. ROW Returns the row number of a cell reference. ROWS Returns the number of rows in an array. TRANSPOSE Flips the oriention of a range of cells. VLOOKUP Lookup a value in the first column and return a value. Date & Time yes DATE Returns a date from year, month, and day. DATEDIF Number of days, months or years between two dates. DATEVALUE Converts a date stored as text into a valid date DAY Returns the day as a number (1-31). DAYS Returns the number of days between two dates. DAYS360 Returns days between 2 dates in a 360 day year. EDATE Returns a date, n months away from a start date. EOMONTH Returns the last day of the month, n months away date. HOUR Returns the hour as a number (0-23). MINUTE Returns the minute as a number (0-59). MONTH Returns the month as a number (1-12). NETWORKDAYS Number of working days between 2 dates. NETWORKDAYS.INTL Working days between 2 dates, custom weekends. NOW Returns the current date and time. SECOND Returns the second as a number (0-59) TIME Returns the time from a hour, minute, and second. TIMEVALUE Converts a time stored as text into a valid time. TODAY Returns the current date. WEEKDAY Returns the day of the week as a number (1-7). WEEKNUM Returns the week number in a year (1-52). WORKDAY The date n working days from a date. WORKDAY.INTL The date n working days from a date, custom weekends. YEAR Returns the year. YEARFRAC Returns the fraction of a year between 2 dates. Engineering yes CONVERT Convert number from one unit to another. Financial yes FV Calculates the future value. PV Calculates the present value. NPER Calculates the total number of payment periods. PMT Calculates the payment amount. RATE Calculates the interest Rate. NPV Calculates the net present value. IRR The internal rate of return for a set of periodic CFs. XIRR The internal rate of return for a set of non-periodic CFs. PRICE Calculates the price of a bond. YIELD Calculates the bond yield. INTRATE The interest rate of a fully invested security. Information yes CELL Returns information about a cell. ERROR.TYPE Returns a value representing the cell error. ISBLANK Test if cell is blank. TRUE/FALSE ISERR Test if cell value is an error, ignores #N/A. TRUE/FALSE ISERROR Test if cell value is an error. TRUE/FALSE ISEVEN Test if cell value is even. TRUE/FALSE ISFORMULA Test if cell is a formula. TRUE/FALSE ISLOGICAL Test if cell is logical (TRUE or FALSE). TRUE/FALSE ISNA Test if cell value is #N/A. TRUE/FALSE ISNONTEXT Test if cell is not text (blank cells are not text). TRUE/FALSE ISNUMBER Test if cell is a number. TRUE/FALSE ISODD Test if cell value is odd. TRUE/FALSE ISREF Test if cell value is a reference. TRUE/FALSE ISTEXT Test if cell is text. TRUE/FALSE N Converts a value to a number. NA Returns the error: #N/A. TYPE Returns the type of value in a cell. Math yes ABS Calculates the absolute value of a number. AGGREGATE Define and perform calculations for a database or a list. CEILING Rounds a number up, to the nearest specified multiple. COS Returns the cosine of an angle. DEGREES Converts radians to degrees. DSUM Sums database records that meet certain criteria. EVEN Rounds to the nearest even integer. EXP Calculates the exponential value for a given number. FACT Returns the factorial. FLOOR Rounds a number down, to the nearest specified multiple. GCD Returns the greatest common divisor. INT Rounds a number down to the nearest integer. LCM Returns the least common multiple. LN Returns the natural logarithm of a number. LOG Returns the logarithm of a number to a specified base. LOG10 Returns the base-10 logarithm of a number. MOD Returns the remainder after dividing. MROUND Rounds a number to a specified multiple. ODD Rounds to the nearest odd integer. PI The value of PI. POWER Calculates a number raised to a power. PRODUCT Multiplies an array of numbers. QUOTIENT Returns the integer result of division. RADIANS Converts an angle into radians. RAND Calculates a random number between 0 and 1. RANDBETWEEN Calculates a random number between two numbers. ROUND Rounds a number to a specified number of digits. ROUNDDOWN Rounds a number down (towards zero). ROUNDUP Rounds a number up (away from zero). SIGN Returns the sign of a number. SIN Returns the sine of an angle. SQRT Calculates the square root of a number. SUBTOTAL Returns a summary statistic for a series of data. SUM Adds numbers together. SUMIF Sums numbers that meet a criteria. SUMIFS Sums numbers that meet multiple criteria. SUMPRODUCT Multiplies arrays of numbers and sums the resultant array. TAN Returns the tangent of an angle. TRUNC Truncates a number to a specific number of digits. Stats yes AVERAGE Averages numbers. AVERAGEA Averages numbers. Includes text & FALSE =0, TRUE =1. AVERAGEIF Averages numbers that meet a criteria. AVERAGEIFS Averages numbers that meet multiple criteria. CORREL Calculates the correlation of two series. COUNT Counts cells that contain a number. COUNTA Count cells that are non-blank. COUNTBLANK Counts cells that are blank. COUNTIF Counts cells that meet a criteria. COUNTIFS Counts cells that meet multiple criteria. FORECAST Predict future y-values from linear trend line. FREQUENCY Counts values that fall within specified ranges. GROWTH Calculates Y values based on exponential growth. INTERCEPT Calculates the Y intercept for a best-fit line. LARGE Returns the kth largest value. LINEST Returns statistics about a trendline. MAX Returns the largest number. MEDIAN Returns the median number. MIN Returns the smallest number. MODE Returns the most common number. PERCENTILE Returns the kth percentile. PERCENTILE.INC Returns the kth percentile. Where k is inclusive. PERCENTILE.EXC Returns the kth percentile. Where k is exclusive. QUARTILE Returns the specified quartile value. QUARTILE.INC Returns the specified quartile value. Inclusive. QUARTILE.EXC Returns the specified quartile value. Exclusive. RANK Rank of a number within a series. RANK.AVG Rank of a number within a series. Averages. RANK.EQ Rank of a number within a series. Top Rank. SLOPE Calculates the slope from linear regression. SMALL Returns the kth smallest value. STDEV Calculates the standard deviation. STDEV.P Calculates the SD of an entire population. STDEV.S Calculates the SD of a sample. STDEVP Calculates the SD of an entire population TREND Calculates Y values based on a trendline. Text yes CHAR Returns a character specified by a code. CLEAN Removes all non-printable characters. CODE Returns the numeric code for a character. CONCATENATE Combines text together. DOLLAR Converts a number to text in currency format. EXACT Test if cells are exactly equal. Case-sensitive. TRUE/FALSE FIND Locates position of text within a cell.Case-sensitive. LEFT Truncates text a number of characters from the left. LEN Counts number of characters in text. LOWER Converts text to lower case. MID Extracts text from the middle of a cell. PROPER Converts text to proper case. REPLACE Replaces text based on it’s location. REPT Repeats text a number of times. RIGHT Truncates text a number of characters from the right. SEARCH Locates position of text within a cell.Not Case-sensitive. SUBSTITUTE Finds and replaces text. Case-sensitive. TEXT Converts a value into text with a specific number format. TRIM Removes all extra spaces from text. UPPER Converts text to upper case. VALUE Converts a number stored as text into a number.

We can get a complete set of relative column numbers in a range with an array formula that is based on the COLUMN function. The steps below will walk through the process.

Figure 1: Result of Relative Column Numbers in a Range:

General Formula

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

Formula

=COLUMN(A3:E3)-COLUMN(A3)+1

Setting up the Data

We will determine the relative column number for range A3:E3 based on the content of figure 2

Figure 2: Setting up the Data

Get Relative Column Numbers in a Range

  • We will highlight the range from Cell A3 to E3
  • We will input the formula below inside the range

{=COLUMN(A3:E3)-COLUMN(A3)+1}

Figure 3: How to Get Relative Column Numbers in a Range

  • Because this is an array formula, we will press CTRL+SHIFT+ENTER to get the result

Figure 4: Result of Relative Column Numbers in a Range

Explanation

In this formula, the first Column function creates an array of 5 numbers like this: {2,3,4,5,6}. The second Column function creates an array that has only one item: {2}. This is subtracted from the first array and results in {0,1,2,3,4}. 1 is added to the result to produce: {1,2,3,4,5}.

Instant Connection to an Expert through our Excelchat Service

Most of the time, the problem you will need to solve will be more complex than a simple application of a formula or function. If you want to save hours of research and frustration, try our live Excelchat service! Our Excel Experts are available 24/7 to answer any Excel question you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.

  1. Select the cell where you want the result to appear.

  2. On the Formulas tab, click More Functions, point to Statistical, and then click one of the following functions:

    • COUNTA: To count cells that are not empty

    • COUNT: To count cells that contain numbers.

    • COUNTBLANK: To count cells that are blank.

    • COUNTIF: To count cells that meets a specified criteria.

      Tip: To enter more than one criterion, use the COUNTIFS function instead.

  3. Select the range of cells that you want, and then press RETURN.

  1. Select the cell where you want the result to appear.

  2. On the Formulas tab, click Insert, point to Statistical, and then click one of the following functions:

    • COUNTA: To count cells that are not empty

    • COUNT: To count cells that contain numbers.

    • COUNTBLANK: To count cells that are blank.

    • COUNTIF: To count cells that meets a specified criteria.

      Tip: To enter more than one criterion, use the COUNTIFS function instead.

  3. Select the range of cells that you want, and then press RETURN.

I’m going to start by reviewing a couple fundamentals about selecting ranges in Excel with VBA, then I’ll discuss methods for selecting ranges with variable row numbers.

Selecting Cells in Excel

One of the most common situations in Microsoft Excel is that you need to select a cell or a range of cells to perform an action. For example, even just to copy and paste content, you need to perform steps below one-by-one (I bet you never thought this was actually a complex task).

  1. Select the cell(s) to be copied
  2. Click on copy (or) ctrl + c
  3. Select the cell(s) into which the content needs to be pasted
  4. Click on paste (or) ctrl + v

In this process, we select one cell or multiple cells that are in continuous rows and columns. This continuous selection is called a “Range”. A range is generally identified by the starting cell reference in the left-side top corner and ending cell reference in the bottom right corner of the selection. For example, in the image below, the range is from C2 to E7. All the cells within this cell reference are selected.

Blank Excel worksheet with a range selected

The Range Expression

VBA offers a Range expression that can be used in selection of cells.

Syntax:

Range (“ < reference starting cell > : < reference ending cell >”)

(or)

Range ( Cells ( <row_number> , <col_number> ) , Cells ( <row_number> , <col_number> ) )

In other words, the range of cells selected in the image above can be expressed in any one of the following ways — for our example, we’ll assume that we are selecting the range on a sheet named “Wonders.”

Sheets("Wonders").Range("C2:E7").Select

Note that letters are used to represent column number and row is indicated by a number. There is a colon in between to two cell references and the entire parameter is encased in double quotes.

Sheets("Wonders").Range(Cells(2, 3), Cells(7, 5)).Select

In this case, double quotes are not used for the range. There is comma instead of the colon symbol, and the cell references are represented using the Cells expression and the row and column numbers.

Try it yourself. Name an Excel sheet “Wonders.” Try running the code below and check the “Wonders” sheet to see what has been selected.

Sub range_demo()
Sheets("Wonders").Range("B2:F6").Select
Sheets("Wonders").Range(Cells(2, 3), Cells(7, 5)).Select
End Sub

Variable row numbers in the Range expression

So far we’ve tried to select a range of cells knowing the exact references of two cells that form the range. Now, it is time to see how to insert a dynamic or varying row or column number in the same expression.

The way to do it is simply with concatenation using double quotes and the ampersand (&) symbol.

Let’s look at some examples.

Color a range of cells up to a dynamically changing last row

In the example below, let’s find the last used row and dynamically use that row in the Range expression. This example will color the selected cells in green.

Sub range_demo()

'declare variable
Dim lastrow As Integer

'initialize variable
lastrow = ActiveSheet.UsedRange.Rows.Count

'Use the variable in the range expression to select
Sheets("Wonders").Range("A2:C" &amp;amp;amp;amp; lastrow).Select

'colour the selected cells in green
With Selection.Interior
        .Pattern = xlSolid
        .PatternColorIndex = xlAutomatic
        .Color = 5296274 'green colour
End With

End Sub

Cell background color of range changed dynamically

Color the font of selected cells up to a specific row input by the user

Below is another example that uses the Cells expression to do the same thing. Here we will change the font color of the selected cells.

Sub range_demo()

'declare variable
Dim row_num As Integer

'initialize variable - enter 6 while running the code
row_num = InputBox("Enter the row number")

'Use the variable in the range expression to select only the first 5 rows of data - not the headers
Sheets("Wonders").Range(Cells(2, 1), Cells(row_num, 3)).Select

'colour the font of selected cells in white
With Selection.Font
        .ThemeColor = xlThemeColorDark1
        .TintAndShade = 0
End With

End Sub

Cell color formatted gray based on user input of range

Use a different runtime number in both cell references

In this example, we’re still not hardcoding the cell references. Three rows starting from the row number input by the user are formatted in “Bold.”

Sub range_demo()

'declare variable
Dim row_num As Integer

'initialize variable - enter 3 while running the code
row_num = InputBox("Enter the row number")

'Use the variable in the range expression to select only the first 3 rows of data starting from the row_num input by the user
Sheets("Wonders").Range(Cells(row_num, 1), Cells((row_num + 3), 3)).Select

'make the font of the selected cells to "Bold"
Selection.Font.Bold = True

End Sub

Cells formatted dynamically based on runtime input

Concatenating both cell references of a simple range expression

Sub range_demo()

'declare variable
Dim row_num As Integer

'initialize variable - enter 7 while running the code
row_num = InputBox("Enter the row number")

'Use the variable in the range expression to select only the first 3 rows of data starting from the row_num input by the user
Sheets("Wonders").Range("A" &amp;amp;amp;amp; row_num &amp;amp;amp;amp; ":C" &amp;amp;amp;amp; row_num + 2).Select

'make the font of the selected cells to "Italics"
Selection.Font.Italic = True

End Sub

Both cell references concatenated

Conclusion

The Range expression in VBA is very useful for calculating and formatting cells in MS Excel. Not just row numbers, but also column numbers can be dynamically inserted to make the best use of the expression. In other words, instead of hard coding the reference directly, we can use a variable that holds the number in the expression.

Column Letter to Number in Excel

Figuring out which row you are in is as easy as you like. But, how do you tell which column you are in now? Excel has 16,384 columns, represented by alphabetic characters in Excel. So, suppose you want to find the column CP. How do you tell?

Yes, it is almost impossible to figure out the column number in Excel. However, nothing to worry about because we have a built-in function called COLUMN in excelColumn function finds out the column numbers of the target cells in excel. It takes one argument which is the target cell as reference. Note that this function does not give the value of the cell as it returns only the column number of the cell. read more, which can tell the exact column number we are in right now or find the column number of the supplied argument.

Table of contents
  • Column Letter to Number in Excel
    • How to Find Column Number in Excel? (with Examples)
      • Example #1
      • Example #2
      • Example #3
      • Example #4
    • Things to Remember
    • Recommended Articles

Excel Column to Number

How to Find Column Numbers in Excel? (with Examples)

You can download this Column to Number Excel template here – Column to Number Excel template

Example #1

We can get the current column number by using the COLUMN function in Excel.

  1. We have opened a new workbook and typed some of the values in the worksheet.

    Excel Column to Numbers example 1.1

  2. Let us say we are in cell D7, and we want to know the column number of this cell.

    Excel Column to Numbers example 1.2

  3. To find the current column number, we must write the COLUMN function in the Excel cell and do not pass any argument; close the bracket.

    Excel Column to Numbers example 1.3

  4. Press the “Enter” key. As a result, we will have a current column number in Excel.

    Excel Column to Numbers example 1.4

Example #2

We can get the column number of the different cells by using the COLUMN function in Excel.

Getting the current column is not the toughest task at all. Suppose we want to know the column number of the cell CP5 and how we get that column number.

  • We can write the COLUMN function and pass the specified cell value in any cells.

Excel Column to Numbers example 2.1

  • Then press the “Enter” key. It will return the column number of CP5.

Excel Column to Numbers example 2.2

We have applied the COLUMN formula in cell D6 and passed the argument as CP5, i.e., cell referenceCell reference in excel is referring the other cells to a cell to use its values or properties. For instance, if we have data in cell A2 and want to use that in cell A1, use =A2 in cell A1, and this will copy the A2 value in A1.read more of CP5 cell. However, unlike normal cell reference, it will not return the value in the cell CP5. Rather, it will return the column number of CP5.

So, the column number of the cell CP5 is 94.

Example #3

We can get how many columns are selected in the range by using the COLUMNS function in Excel.

We have learned how to get the current cell column number and specified cell column number in Excel. But, how do you tell how many columns are selected in the range?

We have another built-in function called the COLUMNS function in excelThe COLUMNS function returns the total number of columns in the given array or collection of references.read more, which can return the number of columns selected in the formula range.

Excel Column to Numbers 2

Assume we want to know how many columns are from the range C5 to N5.

  • We can open the formula COLUMNS in any cell and select the range as C5 toN5.

Excel Column to Numbers example 3.1

  • Press the “Enter” key to get the desired result.

Excel Column to Numbers example 3.2

So totally, we have selected 12 columns in the range C5 to N5.

In this way, by using the COLUMN and COLUMNS function in Excel, we can get the two different kinds of results, which can help us calculate or identify the exact column when dealing with huge datasets.

Example #4

We can change the cell reference form to R1C1 references in Excel.

 By default, we have cell references, all the rows are represented numerically, and all the columns are represented alphabetically.

Excel Column to Numbers example 4.1

It is the usual spreadsheet structure we are familiar with. The cell reference is started with the column alphabet and then followed by row numbers.

As we learned earlier in the article, we need to use the COLUMN function to get the column number. How about changing the column headers from the alphabet to numbers like our row headers? Like the image below.

Example 4.2

It is called ROW-COLUMN reference in Excel. Now, take a look at the below image and the reference type.

Example 4.3

Unlike our standard cell reference, reference starts with a row number followed by a column number, not an alphabet.

Follow the below steps to change it to the R1C1 reference style.

  • We must first go to the “File” and “Options.”

Example 4.4

  • Next, go to “Formulas” under “Options.”

Excel Options

  • Working with “Formulas,” select the checkbox “R1C1 reference style” and click “OK.”

Example 4.6

Once we click “OK,” cells will change to R1C1 references.

Things to Remember

  • The R1C1 cell reference is the rarely followed cell reference in Excel. As a result, we may get confused easily at the start.
  • We see column alphabet first and row number next in normal cell references. But in R1C1 cell references, the row number will come first and the column number.
  • The COLUMN function can return the current column number and the supplied column number.
  • The R1C1 cell reference makes it easy to find the column number easily.

Recommended Articles

This article has been a guide to Column Letter to Numbers in Excel. We discuss finding column numbers in Excel using the COLUMN and COLUMNS functions. You may learn more about Excel from the following articles: –

  • Excel Rows Function
  • Excel Rows vs. Columns
  • Excel Rows and Columns
  • Concatenate Excel Columns

Excel COLUMNS Function (Example + Video)

Excel COLUMNS Function

When to use Excel COLUMNS Function

Excel COLUMNS function can be used when you want to get the number of columns in a specified range or array.

What it Returns

It returns a number that represents the total number of columns in the specified range or array.

Syntax

=COLUMNS(array)

Input Arguments

  • array – it could be an array, an array formula or a reference to a contiguous range of cells.

Additional Notes

  • Even if the array contains multiple rows and columns, only the columns are counted. For example:
    • COLUMNS(A1:B1) returns 2.

    • COLUMNS(A1:B100) also returns 2.

  • This formula can be useful when you want to get a sequence of numbers as you go to the right in your worksheet.
    • For example, if you want 1 in A1, 2 in B1, 3 in C1 and so on, use the following formula =COLUMNS($A$1:A1). As you would drag this to the right, the reference inside it would change and the number of columns in the reference would get incremented by one. For example, when you drag it to column B1, the formula becomes COLUMNS($A$1:B1) which then returns 2.

Excel COLUMNS Function – Examples

Here are two examples of using the Excel COLUMNS function.

Example 1: Finding the number of Columns in an Array

Excel COLUMNS Function - Example 1

In the example above, =COLUMNS(A1:A1) returns 1 as it covers one row (which is A1). Similarly, =COLUMNS(A1:C1) returns 3 as the array A1:C1 covers four columns in it.

Also, note that it only counts the number of columns. Hence, whether the array is A1:C1, or A1:C5, it would return 3 in both the cases.

Example 2: Getting a Sequence of Numbers in a Column

Excel COLUMNS Function - Example 2

Excel COLUMNS function can be used to get a sequence of numbers. Since the first reference is fixed, as you copy the formula down, the second reference changes and so does the row numbers in the array.

Excel COLUMNS Function – Video Tutorial

Related Excel Functions:

  • Excel COLUMN Function.
  • Excel ROW Function.
  • Excel ROWS Function

Other articles you may also like:

  • Row vs Column in Excel – What’s the Difference?

Понравилась статья? Поделить с друзьями:
  • Excel column not filtering
  • Excel column letters are numbers
  • Excel column letter to numbers
  • Excel column letter to number one
  • Excel column is number not letter