I keep getting a "Run Time Error '13': Type Mismatch" error when comparing 2 dates. The code grabs a date from a second Workbook, which in this case I've tried to paste it into a cell to make sure it's a date... Which it is. Then it tries to compare it to a date already on the current Workbook. The pasted date and the other dates are identical formats. I have no idea why it can't compare the 2 dates! I've also tried putting CDate() around each of the components to no avail. Please help.
Sub NewMacro()
Dim CurrentWB As Workbook
Dim ForecastWB As Workbook
Dim strDate As Date
Set CurrentWB = ActiveWorkbook
Application.DisplayAlerts = False
Set ForecastWB = Workbooks.Open("My Other Workbook File Name")
Application.DisplayAlerts = True
strDate = ActiveWorkbook.Worksheets("My Sheet Name").Cells(20, "N").Value
ThisWorkbook.Activate
If Cells(5, 5) = Range("A:A") Then 'TYPE MISMATCH HERE
Set x = Range("A:A").Find(what:=Cells(5, 5), lookat:=xlWhole)
Cells(x, 5) = strDate
End If
End Sub
IsDate()
is true... there may be the chance that at least one date is treated like a string... please see THIS – Dirk ReichelCells(5, 5) = Range("A:A")
be comparing a single cell to a whole column?Cells(5, 5) = Range("A1")
works. – Darren Bartrup-Cook