' @Author - Alexander Bolte' @ChangeDate - 2015-08-19' @Description - This approach works only, if no cells are merged.' If this approach is applied on a worksheet that contains' merged cells the runtime error number '91' will occur' since Excel 2000.'' Check for merged cells and work around this problem' using the getDataRange function.'' The getDataRange is much slower than the getLastColWithData' and getLastRowWithData functions but on the other hand it's' save.'' If the given sheet in the given workbook does not conatin any data,' this function returns -1.' @Param tmpWs - an object of type Worksheet.' @Returns - a Long providing the last column holding data in a provided worksheet independent from its UsedRange.FunctionfuncGetLastColWithData(ByReftmpWSAsWorksheet)AsLongDimlastColAsLongOnErrorGoToerrHandle:' ### unmerge cannot be applied on list objects, since merge is not possible on them ###IftmpWS.ListObjects.Count=0ThenCalltmpWS.Rows.UnMergeCalltmpWS.Columns.UnMergeEndIfWithtmpWSIfApplication.WorksheetFunction.CountA(.Cells)>0ThenlastCol=.Cells.find(What:="*",After:=.Cells(1),_LookIn:=xlFormulas,LookAt:=xlWhole,_SearchOrder:=xlByColumns,_SearchDirection:=xlPrevious).ColumnElselastCol=-1EndIfEndWitherrHandle:funcGetLastColWithData=lastColEndFunction