VBA "Date" not working

jameshunt83

Board Regular
Joined
Oct 2, 2010
Messages
149
I have a workbook with a macro with the below line on it.

Code:
Sub converttoenquiry()
If Range("V2").Value = "" Then Range("V2").Value = Date
End Sub

This worked fine previously however I have just copied the file to another computer and it doesn't seem to like the "Date" part of it. Why is this and how do I fix it?
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Try this:

Press ALT+F11 to open the Visual Basic Editor.
Click Tools -> References
Clear the check box for the type library or object library marked as "Missing:"
 
Upvote 0
This is a great fix, and works for me too, the problem is with the "Microsoft Excel 12.0 Object Library".

However, is there any way for me to stop this error happening? I would rather not have to ask my users to go into the VBA editor and uncheck libraries... This, to them, is like computer hacking and rocket science :(

I use Excel 2007 and most of my colleagues use Excel 2003. I don't use any of the features specific to 12.0, as I need my macros to work on Excel 2003.

Is there some way I can force my Excel 2007 to use the 11.0 object library instead of the 12.0, and stop this problem ??
 
Upvote 0

Forum statistics

Threads
1,224,564
Messages
6,179,543
Members
452,924
Latest member
JackiG

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top