Finding the last used column on any given row is useful in Excel when automating tasks or creating a database. It is especially useful when your dataset may expand and contract from a static size and area. Used in conjunction with the last used row creates a powerful process for VBA and data automation.
It can be used as a standalone stored procedure or pasted into a module and adapted as you see fit for purpose.
This particular piece of code is used in the majority of our projects and certainly in projects where data is analysed, moved or manipulated in any way.
Feel free to ask us a question, or comment below…
Public Sub Last_used_Column()
LastCol = .Cells(1, .Columns.Count).End(xlToLeft).Column