Skip to content

Instantly share code, notes, and snippets.

@stevehenderson
Created May 15, 2013 04:01
Show Gist options
  • Save stevehenderson/5581574 to your computer and use it in GitHub Desktop.
Save stevehenderson/5581574 to your computer and use it in GitHub Desktop.
VBA helper function to find the final column of data on a worksheet (VBA, last, column, find, helper)
'A helper function to find the final column of data on a worksheet
'
'To use, provide the name of the worksheet
'The function assumes the data starts in cell A1
'and will return the column number of the column of data
'
'Author: Steve Henderson [email protected]
'
Function findLastColumn(sheetName As String)
' Find the last column with data
Set WS = Worksheets(sheetName)
findLastColumn = WS.Cells(1, Application.Columns.Count).End(xlToLeft).Column
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment