I am using the following code to find the last row that contains data, within a particular column on a spreadsheet.
It works for columns that contain only numbers. However, for cells that contain formulas, I get the following message:
This is independent of the declared type of GetLastRowWithD ata (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!
Code:
Dim ws As Worksheet Set ws = Worksheets(Me.ChartDataSheetName) GetLastRowWithData = ws.Cells(ws.Rows.Count, dataCol).End(xlUp).row
Code:
Run Time Error 13 Type Mismatch
Any suggestions as to why this might not be working would be appreciated!