index > Visual Basic for Applications (VBA) > Left, Mid and Right functions not working on Office 2003

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




SA
CReME
Hi,

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

bvr
bvravi

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
ADG
reply 3

You can use google to search for other answers

 

More Articles

• Excel Range Selection
• dtpicker MicrosoftWord Template
• Vlookup from various files
• how to import .xml file to excel and grab data from the .xml fil...
• Runtime err 1004 when attempting to set data range for existing c...
• Input from user form put into specified cell.
• setting up new email
• VBA, Visio, Excel and ExecuteLine
• Outlook 2003 VBA - AdvancedSearch in a personal folder (*.pst dat...
• Saving information in a form
Welcome to Bokebb   New Update   Joins the collection  
 

New Articles

• Can any1 arrange the ADO connection logi
• Runtime error 1004 when adding a seriesc
• won't recognize DisplayControl Property
• If your users reference an XLA on the ne
• VBA Excel: PivotTable Visibility and Piv
• Using of APC.IDE.PreventShow property
• Need to Count the replacements made by a
• Preventing keyboard shortcuts
• Adding minimize button to userform in de
• Code erroring out.
• VBA code to search and modify in Word
• Extract code from .dot
• VBA and Excel Deleting Worksheets withou
• Command Buttons (Delete, Run, and Close)
• Unable to create .NET class in VBA

Hot Articles

• Serial Port Communication Using MS Acces
• VB6 XP Themes support. Solved! Source in
• Urgent help regarding line chart thru Ex
• how to connect two locations to better c
• document title
• Changing chart series
• copying links from specific cells in a w
• Missing record
• RunTime Error '13' Type Mismatch
• access populate combo box help needed
• Urgent HELP!!!!! VB in MS Excel
• Read data from excel through VB.NET
• calling a function and passing the name
• UTC Dates
• combine 3 combo boxes values into one st

Recommend Articles

• For Each Next Loop
• How to stop a never ending loop
• transmitting a string from excel to com1
• read only file opening
• Copy and Paste Values
• Check diff
• Urgent help regarding line chart thru Ex
• Where is the command button on microsoft
• Macro to sort an Excel column
• Program code fro sorting coloumns in a l
• Search list
• When to program in VBA and when not to???
• Excel Workbook corrupting
• Working with Outlook Public Folders from
• VBA Module to DLL