I am using the following code to find the last row that contains data, within a particular column on a spreadsheet.
- Dim ws As Worksheet
-
Set ws = Worksheets(Me.ChartDataSheetName)
-
GetLastRowWithData = ws.Cells(ws.Rows.Count, dataCol).End(xlUp).row
It works for columns that contain only numbers. However, for cells that contain formulas, I get the following message:
- Run Time Error 13
-
Type Mismatch
This is independent of the declared type of GetLastRowWithData (i.e. I get the message whether it is Integer or Long). Note that it works with columns containing numbers.
Any suggestions as to why this might not be working would be appreciated!