Left, Mid and Right functions not working on Office 2003

Hi,

VB in office 2003 does not seem to recognise the Left, Mid and Right functions. I've been using the code below to convert dates in excel like "20060123" to an actual date (i.e. 23/01/2006) in previous versions with no problem.

Sub DCDecToKhanya()
Dim mycell

For Each mycell In Selection
'For each cell in the range selected

mycell = DateValue(Left(mycell, 4) & "/" & Mid(mycell, 5, 2) & "/" & Right(mycell, 2))
'Convert the contents to a date

Next mycell

End Sub

I get a Compile Error " Can't find project or library"

Thanks

[662 byte] By [CReME] at [2007-12-24]
# 1
Hi,

Please check "Tools > References" in VBA editor for any missing dlls.

bvr

bvravi at 2007-8-31 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...
# 2

Hi

I ran your code in my version of 2003, and it worked OK I changed mycell = DateValue(Left(mycell, 4) & "/" & Mid(mycell, 5, 2) & "/" & Right(mycell, 2)) to mycell.value = DateValue(Left(mycell, 4) & "/" & Mid(mycell, 5, 2) & "/" & Right(mycell, 2)) as I did not get the cells updated. I guess you have some references unticked.

I have Visual Basic for Applications; Microsoft Excel 11 Object Library; OLE automation; and Microsoft Office 11 Object Library all ticked in the references under the tools menu option.

ADG at 2007-8-31 > top of Msdn Tech,Microsoft ISV Community Center Forums,Visual Basic for Applications (VBA)...