What is last column in excel

Home / Excel Basics / What is a Column in Excel

A column in Excel is a vertical alignment of cells. Each column has its unique address, which is labeled as an alphabet (from A to XFD). And there are more than one million cells in a single column and there are a total of 16384 columns that you have in a single worksheet.

referring-to-column

Select a Column

To select a column, you simply need to click on the header of the column where you have the column alphabet, and it will select the entire column from the first cell to the last.

referring-to-single-column

Another way to select an entire column is to use the keyboard shortcut. Once you select any of the cells from the column that you want to select, press, and hold the control key, and then press the spacebar. This will select the entire column.

Related: Keyboard Shortcuts for Excel (PDF Cheat Sheet)

Referring to a Column in Excel

As I said and you can also see in the above snapshot that each column has its unique name, which is made up of the alphabet. Now, to refer to a column, you need to use its name. If you want to refer to column A, then you need to use its address like A:A.

referring-to-a-column-using-address

In the above example, you can see we are referring to column A by using its address in the sum function. Now if you want to refer to multiple columns you can use an address that refers to the multiple columns.

referring-to-multiple-adjacent-columns

Now in the above example, we are referring to the four columns from A to D and in the address, we have used the A:D which means from column A to column D.

referring-two-non-continues-columns

And in the above example, we are referring to two columns that are non-continues and we have used refer to them using their address separately using a comma in between.

What is the Last Column in Excel

The last column in Excel is column XFD. In a single worksheet, there are 16384 columns. This count is fixed you can’t add more columns to a single worksheet and if you want to add more data, you need to insert a new worksheet which further will have 16384 columns.

total-16384-columns

Can I Have the Column Name as a Number?

Yes, you can have a column name as a number instead of an alphabet. For this, you need to change the reference style to R1C1.

column-name-as-number

With R1C1, you can change the column reference, and this allows you to refer to a column using a number. For this go to the File Tab ➜ Options ➜ Working with formulas. Then tick mark “R1C1 reference style”.

change-the-column-reference

But before switching to it make sure to read about it.

Содержание

  1. What Are Columns In Excel?
  2. What are the rows and columns in Excel?
  3. What is column with example?
  4. What is row and column?
  5. What comes first row or column?
  6. What is row and?
  7. What are columns used for?
  8. What column means?
  9. How do I use columns in Excel?
  10. What is column in Table?
  11. Is a column across or down?
  12. What is Cell of MS Excel?
  13. What is the difference between row and column in a table?
  14. What is the matrix called?
  15. Why is Julia column-major?
  16. What is column article?
  17. How many column are there in Excel?
  18. How can you split a table?
  19. What are the 3 main parts of a column?
  20. Why are columns so strong?
  21. What is difference between column and columns in Excel?
  22. Locate and reset the last cell on a worksheet
  23. Locate the last cell that contains data or formatting on a worksheet
  24. Clear all formatting between the last cell and the data
  25. Need more help?
  26. How to Find the Last Used Row and Column in Excel VBA?
  27. Implementation:
  28. An Excel Blog For The Real World
  29. Find Last Row Or Last Column With VBA Code (Best Way)
  30. Dynamic VBA Code With Last Row/Column
  31. Prep Your Excel Data!
  32. How do I find the last column with data?
  33. 7 Answers 7

What Are Columns In Excel?

In Microsoft Excel, a column runs vertically in the grid layout of a worksheet. Vertical columns are numbered with alphabetic values such as A, B, C. Horizontal rows are numbered with numeric values such 1, 2, 3.

What are the rows and columns in Excel?

Row and Column Basics
MS Excel is in tabular format consisting of rows and columns. Row runs horizontally while Column runs vertically. Each row is identified by row number, which runs vertically at the left side of the sheet. Each column is identified by column header, which runs horizontally at the top of the sheet.

What is column with example?

A column is a vertical series of cells in a chart, table, or spreadsheet. Below is an example of a Microsoft Excel spreadsheet with column headers (column letter) A, B, C, D, E, F, G, and H. As you can see in the image, the last column H is the highlighted column in red and the selected cell D8 is in the D column.

What is row and column?

A row is a series of data put out horizontally in a table or spreadsheet while a column is a vertical series of cells in a chart, table, or spreadsheet. Rows go across left to right. On the other hand, Columns are arranged from up to down.

What comes first row or column?

By convention, rows are listed first; and columns, second. Thus, we would say that the dimension (or order) of the above matrix is 3 x 4, meaning that it has 3 rows and 4 columns. Numbers that appear in the rows and columns of a matrix are called elements of the matrix.

What is row and?

1 : a number of objects arranged in a usually straight line a row of bottles also : the line along which such objects are arranged planted the corn in parallel rows. 2a : way, street.

What are columns used for?

Columns are frequently used to support beams or arches on which the upper parts of walls or ceilings rest. In architecture, “column” refers to such a structural element that also has certain proportional and decorative features.

What column means?

Definition of column
1a : a vertical arrangement of items printed or written on a page columns of numbers. b : one of two or more vertical sections of a printed page separated by a rule or blank space The news article takes up three columns. c : an accumulation arranged vertically : stack columns of paint cans.

How do I use columns in Excel?

To insert columns:

  1. Select the column heading to the right of where you want the new column to appear. For example, if you want to insert a column between columns D and E, select column E.
  2. Click the Insert command on the Home tab. Clicking the Insert command.
  3. The new column will appear to the left of the selected column.

What is column in Table?

A column is collection of cells aligned vertically in a table. A field is an element in which one piece of information is stored, such as the eceived field. Usually, a column in a table contains the values of a single field.

Is a column across or down?

Columns run vertically, up and down.Rows, then, are the opposite of columns and run horizontally.

What is Cell of MS Excel?

Cells are the boxes you see in the grid of an Excel worksheet, like this one. Each cell is identified on a worksheet by its reference, the column letter and row number that intersect at the cell’s location. This cell is in column D and row 5, so it is cell D5. The column always comes first in a cell reference.

What is the difference between row and column in a table?

Rows are a group of cells arranged horizontally to provide uniformity. Columns are a group of cells aligned vertically, and they run from top to bottom.

What is the matrix called?

A matrix (whose plural is matrices) is a rectangular array of numbers, symbols, or expressions, arranged in rows and columns. A matrix with m rows and n columns is called an m×n m × n matrix or m -by-n matrix, where m and n are called the matrix dimensions.

Why is Julia column-major?

Probably because most numeric libraries were originally written in Fortran, which uses column-major storage, which then mimics the fact that vectors in math are by convention columns. Same applies to Matlab, which started as a convenient way to speak to some Fortran linear algebra packages.

What is column article?

A column is a recurring piece or article in a newspaper, magazine or other publication, where a writer expresses their own opinion in few columns allotted to them by the newspaper organisation. Columns are written by columnists.

How many column are there in Excel?

Worksheet and workbook specifications and limits

Feature Maximum limit
Open workbooks Limited by available memory and system resources
Total number of rows and columns on a worksheet 1,048,576 rows by 16,384 columns
Column width 255 characters
Row height 409 points

How can you split a table?

Split a table

  1. Put your cursor on the row that you want as the first row of your second table. In the example table, it’s on the third row.
  2. On the LAYOUT tab, in the Merge group, click Split Table. The table splits into two tables.

What are the 3 main parts of a column?

Classical columns traditionally have three main parts:

  • The base. Most columns (except the early Doric) rest on a round or square base, sometimes called a plinth.
  • The shaft. The main part of the column, the shaft, may be smooth, fluted (grooved), or carved with designs.
  • The capital.

Why are columns so strong?

Columns are vertical structural members designed to pass through a compressive load.Engineers have to design columns that are very strong under compression in order to keep buildings safe.

What is difference between column and columns in Excel?

Each row has a unique number that identifies it. A column is a vertical line of cells. Each column has a unique letter that identifies it.
Comparative Table.

Источник

Locate and reset the last cell on a worksheet

When you save a workbook, Excel stores only the part of each worksheet that contains data or formatting. Empty cells may contain formatting that causes the last cell in a row or column to fall outside of the range of cells that contains data. This causes the file size of the workbook to be larger than necessary and may result in more printed pages when you print the worksheet or workbook.

To avoid these issues, you can locate the last cell that contains data or formatting on a worksheet, and then reset that last cell by clearing all of the formatting that may be applied in empty rows or columns between the data and the last cell.

Locate the last cell that contains data or formatting on a worksheet

To locate the last cell that contains data or formatting, click anywhere in the worksheet, and then press CTRL+END.

Note: To select the very last cell in a row or column, press END, and then press the RIGHT ARROW key or the DOWN ARROW key.

Clear all formatting between the last cell and the data

Do one of the following:

To select all columns to the right of the last column that contains data, click the first column heading, hold down CTRL, and then click the column headings of the columns that you want to select.

Tip: You can also click the first column heading, and then press CTRL+SHIFT+END.

To select all rows below the last row that contains data, click the first row heading, hold down CTRL, and then click the row headings of the rows that you want to select.

Tip: You can also click the first row heading, and then press CTRL+SHIFT+END.

On the Home tab, in the Editing group, click the arrow next to the Clear button , and then click Clear All.

Save the worksheet.

Close the worksheet.

When you open the workbook again, the last cell of the data should be the last cell on the worksheet.

Need more help?

You can always ask an expert in the Excel Tech Community or get support in the Answers community.

Источник

How to Find the Last Used Row and Column in Excel VBA?

We use Range.SpecialCells() method in the below VBA Code to find and return details of last used row, column, and cell in a worksheet.

Sample Data:

Syntax:

Eg: To return the last used cell address in an activesheet. ActiveSheet.Range(“A1”).SpecialCells(xlCellTypeLastCell).Address

VBA Code:

Variable Data Type Comments
LastRow Long Find and store last used row
LastCol Long store last used column
LastCell String store last used cell address

Use SpecialCells function to find last used row/column/cell

Concatenate all three variables (LastRow/LastCol/LastCell), add a new line between variables use Chr(10). Show the final output in an Excel Message box.

Implementation:

Follow the below steps to find the Last Used Row and Last Used Column in Excel VBA

Step 1: Add a shape (Find Last Row/Column/Cell) on your worksheet.

Step 2: Right-click on “Find Last Row/Column/Cell” and “Assign Macro..”

Step 3: Select “findLastUsedCell”, you can see a list of macros if available in your workbook

Step 4: Save your excel file as “Excel Macro-Enabled Workbook” *.xlsm

Step 5: Click “Find Last Row/Column/Cell” to execute the VBA code. Code will popup below output for the above given example (Output).

Источник

An Excel Blog For The Real World

A blog focused primarily on Microsoft Excel, PowerPoint, & Word with articles aimed to take your data analysis and spreadsheet skills to the next level. Learn anything from creating dashboards to automating tasks with VBA code!

Find Last Row Or Last Column With VBA Code (Best Way)

Dynamic VBA Code With Last Row/Column

Finding the Last Row or Last Column within your VBA code is key to ensuring your macro doesn’t break in the future.

Early on when I first began writing VBA macro code, I always needed to go back into the code and modify range references. I had created a bunch of macros to clean up and perform analysis on raw data exported from databases and the data never had the same amount of rows from one data pull to the next.

My coding skills dramatically changed the day I realized my VBA code could be dynamic and automatically determine the size of my raw data once executed. I soon came to realize the goal of coding a macro: to write it once and never touch it again.

Variability is also the greatest challenge for any VBA coder as you have to think of every possible change that could occur in the future. I have found writing VBA code that can automatically resize itself is one of the greatest things missing from most average macro user’s code.

In this article, I have compiled a list of the best methods you can use to accomplish finding the last row or column in your data range.

Prep Your Excel Data!

Keep in mind some of these methods may not give you the desired row or column number if you are not setting your spreadsheet up properly or using a well-formatted block of data.

What I mean by a “well-formatted block of data”, is a worksheet with data that starts in cell A1 and does not have any blank rows or columns in the middle of the data.

The below figure illustrates the difference.

Источник

How do I find the last column with data?

I’ve found this method for finding the last data containing row in a sheet:

Is there a similar method for finding the last data containing column in a sheet?

7 Answers 7

Lots of ways to do this. The most reliable is find.

If you want to find the last column used in a particular row you can use:

Using used range (less reliable):

Using used range wont work if you have no data in column A. See here for another issue with used range:

See Here regarding resetting used range.

I know this is old, but I’ve tested this in many ways and it hasn’t let me down yet, unless someone can tell me otherwise.

Try using the code after you active the sheet:

If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a «Save file» action. But use UsedRange will always update the information in realtime.

I think we can modify the UsedRange code from @Readify’s answer above to get the last used column even if the starting columns are blank or not.

So this lColumn = ws.UsedRange.Columns.Count modified to

this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count — 1 will give reliable results always

Above line Yields 9 in the immediate window.

Источник


In this article, we will learn to return the Last column of data in Excel.

Scenario:

In simple words, while working with long unmannerly data, and then if needed to extract the column number of the last cell from range. We can use the below explained formula in Excel and can use the same in formulas to feed the row value. The formula considers all kinds of data types and blank cells in between range arrays.

For this article we will be needing the use the following functions:

  1. MIN function
  2. COLUMN function
  3. COLUMNS function

Now we will make a formula out of these functions. Here we will give a list of values as data. We need to find the column of the last cell value in the given input data or say the last non-blank cell in the range.

Syntax:

data : list of values having data.

Example:

All of these might be confusing to understand. So, let’s test this formula via running it on the example shown below. Here we will perform the formula over values and significance with the range data.

Use the formula:

«range» argument given as named range for the array A1:AA4 in the above formula

Explanation:

  • COLUMN function returns a range of values from the first cell column index to the last cell column index.
  • COLUMNS function returns the number of columns in the range.
  • MIN(COLUMN(range)) returns the lowest count of cells in the column in range. 
  • =MIN(COLUMN(range))+COLUMNS(range)-1 returns the last column number from the last cell.


Here the array to the function is given as the named range. Press Enter to get the last column number as result.

As you can see in the above snapshot the column number of the last non blank cell is 27. You can feed the result with other functions to extract different results.

Value from the last non blank cell.

Use the INDEX function to get the value from the last column of data.

Use the formula:


As you can see from the above formula you can get the date value from the last column as well.

Here are some observational notes using the above formula.

Notes:

  1. The formula returns the last column index as a result.
  2. The formula returns a number and can be fed to other functions as number argument.
  3. Named range in the formula be used with correct keywords.

Hope this article about How to Find the Last column of data in Excel is explanatory. Find more articles on reference formulas here. If you liked our blogs, share it with your fristarts on Facebook. And also you can follow us on Twitter and Facebook. We would love to hear from you, do let us know how we can improve, complement or innovate our work and make it better for you. Write to us at info@exceltip.com.

Related Articles:

How to use the INDEX function : Return the value with the index position from the array in Excel using INDEX function.

Find the last row with mixed data in Excel : working with long unmannered numbers, text or blank cell data. Extract the last row with non blank cell using the formula in Excel.

Finding the Last Day of a Given Month : Returns the last day of a given month.

How to Get Last Value In Column : Find the last value in a column or list.

Difference with the last non blank cell : Returns the SUM of values between given dates or period in excel.

Popular Articles:

50 Excel Shortcuts to Increase Your Productivity | Get faster at your task. These 50 shortcuts will make you work ODD faster on Excel.

The VLOOKUP Function in Excel | This is one of the most used and popular functions of excel that is used to lookup value from different ranges and sheets. 

COUNTIF in Excel 2016 | Count values with conditions using this amazing function. You don’t need to filter your data to count specific values. Countif function is essential to prepare your dashboard.

How to Use SUMIF Function in Excel | This is another dashboard essential function. This helps you sum up values on specific conditions.

What is the label of the last column in Excel? Answer: Originally Answered: What is the last column in Excel? Column XFD (or 16384-th column) for Excel 2007 and newer.

Also, What features of Microsoft Excel you are acquainted with?

Features of Microsoft Excel

  • Add Header and Footer. MS Excel allows us to keep the header and footer in our spreadsheet document.
  • Find and Replace Command. …
  • Password Protection. …
  • Data Filtering. …
  • Data Sorting. …
  • Built-in formulae. …
  • Create different charts (Pivot Table Report) …
  • Automatically edits the result.

How columns are Labelled in Excel? By default, Excel uses the A1 reference style, which refers to columns as letters (A through IV, for a total of 256 columns), and refers to rows as numbers (1 through 65,536). These letters and numbers are called row and column headings. To refer to a cell, type the column letter followed by the row number.

Which is the correct syntax in Excel?

In order to work correctly, a function must be written a specific way, which is called the syntax. The basic syntax for a function is an equals sign (=), the function name (SUM, for example), and one or more arguments.

2. Hold down CTRL and press the right arrow key (cursor key) on the keyboard. You are taken to the right-most column. In the modern versions of Excel this is column XFD, which is 16,384 columns. … In the modern versions of Excel there are 1,048,576 rows.

What are the four features of MS Excel?

Ans. The main features of MS Excel include inserting a pivot table, sorting of tabulated data, adding formulas to the sheet, and calculating large data.

What is MS Excel and features?

Microsoft Excel is a spreadsheet developed by Microsoft for Windows, macOS, Android and iOS. It features calculation, graphing tools, pivot tables, and a macro programming language called Visual Basic for Applications (VBA). … Excel forms part of the Microsoft Office suite of software.

What are the disadvantages of MS Excel?

11 Disadvantages of Using Excel to Manage Your Pricing

  • Difficult to manage advanced pricing rules. …
  • Lack of control and security. …
  • Excel is vulnerable to fraud/corruption. …
  • Excel is susceptible to human error. …
  • Excel is difficult to troubleshoot or test. …
  • Excel is obstructive to regulatory compliance.

How cells are named in MS Excel?

Each cell in the spreadsheet has a corresponding name, which is identified by its column letter and row number. For instance, the cell under column A that belongs to row 1 has the default name A1. You will see this in the name box, which is located on the upper left side of the spreadsheet, next to the formula bar.

What are the blocks in Excel called?

The cell. An Excel worksheet is made up of columns and rows. Where these columns and rows intersect, they form little boxes called cells.

How do you label rows in Excel?

What are the 5 functions in Excel?

5 Functions of Excel/Sheets That Every Professional Should Know

  • VLookup Formula.
  • Concatenate Formula.
  • Text to Columns.
  • Remove Duplicates.
  • Pivot Tables.

What is cheat sheet in Excel?

Math functions Excel Formulas Cheat Sheet

=SUM – add the total of a series of numbers. =AVERAGE – calculates the average of a series of numbers. =MEDIAN – returns the median average number of a series. =SUMPRODUCT – calculates the weighted average, very useful for financial analysis.

What does the VLOOKUP function do in MS Excel?

VLOOKUP stands for ‘Vertical Lookup’. It is a function that makes Excel search for a certain value in a column (the so called ‘table array’), in order to return a value from a different column in the same row.

Does Excel sheet end?

In a 26 base system, the value XFD equals 16384. Excel 2007 and above supports 2^20 rows, i.e. 1048576 rows. They are just numbered from 1 to 1048576.

Why is Excel 1048576?

I mail merged my constituent database into an excel sheet and it only shows 1,048,576 rows, why is this? Answer: Excel Spreadsheets only hold 1,048,576 rows by 16,384 columns.

What is cell in Excel?

Cells are the boxes you see in the grid of an Excel worksheet, like this one. Each cell is identified on a worksheet by its reference, the column letter and row number that intersect at the cell’s location. This cell is in column D and row 5, so it is cell D5. The column always comes first in a cell reference.

How many types of MS Excel?

Excel 2010’s Three Data Types and Their Default Formats.

What is Vlookup in Excel?

VLOOKUP stands for ‘Vertical Lookup’. It is a function that makes Excel search for a certain value in a column (the so called ‘table array’), in order to return a value from a different column in the same row.

What is Excel ribbon?

First introduced in Excel 2007, the ribbon is the strip of buttons and icons located above the work area. The ribbon replaces the menus and toolbars found in earlier versions of Excel.

What is Excel written in?

Thank you so much. Excel and MS Office is written in plain and simple C. There are a few books about it and websites. A few things in the front end gui are quite possibly written in either C++.

Why is Excel called Excel?

Microsoft originally marketed a spreadsheet program called Multiplan in 1982, which was very popular on CP/M systems, but on MS-DOS systems it lost popularity to Lotus 1-2-3. This promoted development of a new spreadsheet called Excel which started with the intention to ‘do everything 1-2-3 does and do it better’.

I’ve found this method for finding the last data containing row in a sheet:

ws.Range("A65536").End(xlUp).row

Is there a similar method for finding the last data containing column in a sheet?

jamheadart's user avatar

jamheadart

4,9684 gold badges29 silver badges62 bronze badges

asked Aug 13, 2012 at 0:33

Neat Machine's user avatar

4

Lots of ways to do this. The most reliable is find.

Dim rLastCell As Range

Set rLastCell = ws.Cells.Find(What:="*", After:=ws.Cells(1, 1), LookIn:=xlFormulas, LookAt:= _
xlPart, SearchOrder:=xlByColumns, SearchDirection:=xlPrevious, MatchCase:=False)

MsgBox ("The last used column is: " & rLastCell.Column)

If you want to find the last column used in a particular row you can use:

Dim lColumn As Long

lColumn = ws.Cells(1, Columns.Count).End(xlToLeft).Column

Using used range (less reliable):

Dim lColumn As Long

lColumn = ws.UsedRange.Columns.Count

Using used range wont work if you have no data in column A. See here for another issue with used range:

See Here regarding resetting used range.

Community's user avatar

answered Aug 13, 2012 at 2:00

Reafidy's user avatar

ReafidyReafidy

8,2505 gold badges49 silver badges81 bronze badges

8

I know this is old, but I’ve tested this in many ways and it hasn’t let me down yet, unless someone can tell me otherwise.

Row number

Row = ws.Cells.Find(What:="*", After:=[A1] , SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row

Column Letter

ColumnLetter = Split(ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Cells.Address(1, 0), "$")(0)

Column Number

ColumnNumber = ws.Cells.Find(What:="*", After:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column

answered Apr 19, 2016 at 11:52

xn1's user avatar

xn1xn1

4174 silver badges12 bronze badges

Try using the code after you active the sheet:

Dim J as integer
J = ActiveSheet.UsedRange.SpecialCells(xlCellTypeLastCell).Row

If you use Cells.SpecialCells(xlCellTypeLastCell).Row only, the problem will be that the xlCellTypeLastCell information will not be updated unless one do a «Save file» action. But use UsedRange will always update the information in realtime.

Rob's user avatar

Rob

4,91712 gold badges52 silver badges54 bronze badges

answered May 22, 2013 at 6:55

Peter's user avatar

PeterPeter

211 bronze badge

1

I think we can modify the UsedRange code from @Readify’s answer above to get the last used column even if the starting columns are blank or not.

So this lColumn = ws.UsedRange.Columns.Count modified to

this lColumn = ws.UsedRange.Column + ws.UsedRange.Columns.Count - 1 will give reliable results always

enter image description here

?Sheet1.UsedRange.Column + Sheet1.UsedRange.Columns.Count - 1

Above line Yields 9 in the immediate window.

Community's user avatar

answered Mar 11, 2016 at 16:36

Stupid_Intern's user avatar

Stupid_InternStupid_Intern

3,3628 gold badges36 silver badges74 bronze badges

Here’s something which might be useful. Selecting the entire column based on a row containing data, in this case i am using 5th row:

Dim lColumn As Long

lColumn = ActiveSheet.Cells(5, Columns.Count).End(xlToLeft).Column
MsgBox ("The last used column is: " & lColumn)

answered Jun 27, 2018 at 9:09

dapaz's user avatar

dapazdapaz

80310 silver badges16 bronze badges

2

I have been using @Reafidy method/answer for a long time, but today I ran into an issue with the top row being merged cell from A1—>N1 and my function returning the «Last Column» as 1 not 14.

Here is my modified function now account for possibly merged cells:

Public Function Get_lRow(WS As Worksheet) As Integer
 On Error Resume Next
 If Not IsWorksheetEmpty(WS) Then
  Get_lRow = WS.Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).Row
  Dim Cell As Range
  For Each Cell In WS.UsedRange
   If Cell.MergeCells Then
    With Cell.MergeArea
     If .Cells(.Cells.Count).Row > Get_lRow Then Get_lRow = .Cells(.Cells.Count).Row
    End With
   End If
  Next Cell
 Else
  Get_lRow = 1
 End If
End Function

Public Function Get_lCol(WS As Worksheet) As Integer
 On Error Resume Next
 If Not IsWorksheetEmpty(WS) Then
  Get_lCol = WS.Cells.Find(What:="*", after:=[A1], SearchOrder:=xlByColumns, SearchDirection:=xlPrevious).Column
  Dim Cell As Range
  For Each Cell In WS.UsedRange
   If Cell.MergeCells Then
    With Cell.MergeArea
     If .Cells(.Cells.Count).Column > Get_lCol Then Get_lCol = .Cells(.Cells.Count).Column
    End With
   End If
  Next Cell
 Else
  Get_lCol = 1
 End If
End Function

answered Nov 8, 2021 at 19:41

FreeSoftwareServers's user avatar

Here’s a simple option if your data starts in the first row.

MsgBox "Last Row: " + CStr(Application.WorksheetFunction.CountA(ActiveSheet.Cells(1).EntireRow))

It just uses CountA to count the number of columns with data in the entire row.

This has all sorts of scenarios where it won’t work, such as if you have multiple tables sharing the top row, but for a few quick & easy things it works perfect.

answered Dec 3, 2021 at 19:32

Alex Kwitny's user avatar

Alex KwitnyAlex Kwitny

10.9k2 gold badges48 silver badges70 bronze badges

Понравилась статья? Поделить с друзьями:
  • What is meaning of word a professional
  • What is loan word
  • What is meaning of word a profession
  • What is list object in excel vba
  • What is meaning of odd word