The below code should work in all versions of Excel (if not, please let me know):
Function GetColumnCount(WorksheetName As String, RowNumber As Long) As Long With Worksheets(WorksheetName) GetColumnCount = .Cells(RowNumber, .Columns.Count).End(xlToLeft).Column End With End Function