Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
run time error
why would code such as this cause an error?
sub test() dim maturitydate as date maturitydate=cells(1,1) end sub cells(1,1), in this particular case, is empty, or so it seems. the spreadsheet formula in cells(1,1) is: ="" when cells(1,1) is 6/30/06 it runs fine. when formula has ="" i expect code to return 'empty', but it stops for some reason. thx |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
run time error
Hi Mike,
If the cell's value cannot be interpreted as a date, the code will fail with a type mismatch error. Try: '============= Sub test() Dim maturitydate As Date With Cells(1, 1) If IsDate(.Value) Then maturitydate = .Value End If End With End Sub '<<============= --- Regards, Norman "mike allen" wrote in message ... why would code such as this cause an error? sub test() dim maturitydate as date maturitydate=cells(1,1) end sub cells(1,1), in this particular case, is empty, or so it seems. the spreadsheet formula in cells(1,1) is: ="" when cells(1,1) is 6/30/06 it runs fine. when formula has ="" i expect code to return 'empty', but it stops for some reason. thx |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Visual Basic Error Run Time Error, Type Mismatch | Excel Discussion (Misc queries) | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Befuddled with For Next Loop ------ Run - Time Error '13' Type Mismatch Error | Excel Programming | |||
Code Error - Run Time Error 5 (Disable Cut, Copy & Paste) | Excel Programming | |||
Run-time error '11' & Run-time error '1004' | Excel Programming |