Very Strange Error when using Format()

  • Thread starter Thread starter wjoc1
  • Start date Start date
W

wjoc1

Guys,

This is a new one to me anyways. I was wondering if anyone could she
any light on it for me. This has to be the simplest piece of vb cod
ever, and it works in another workbook no questions asked!!???


Code
-------------------

Dim fmtDate As String

fmtDate = Format(Date, "mmm-yy")

-------------------


When I compile the code I get the if highlights *Format* and I get the
following error

Compile Error:
Wrong number of arguments or invalid property assignment

What the hell am I doing wrong? As I said, same version of exce
different workbook this works fine... as it should.

Thanks,
Lia
 
Liam,
I had no problem using your line of code: fmtDate = Format(Date,
"mmm-yy")

But you could try 'Now()' instead of 'Date'
E.G.
fmtDate = Format(Now(), "mmm-yy")

Peter
 
Do you have a global or procedure variable named Date that's overriding
the Date method?

Or your own Format method?
 
Pete,

I've tried things like that and it doesn't do any good. It's a reall
wierd one, I have the same code in other workbooks and it works fine,
wonder has this workbook I'm working in become correupted or something/

Lia
 
JE,

That's it. The new workbook I tried to use this in was very complex and
hidden away in a litle corner of it was a Format() method. Ha ha.


Thanks a million,
Liam
 
Liam
I' m having the same problem with
"Wrong number of arguments or invalid property assignment" on the word
"Format" in the following code:
txtDate.Text = Format(Date, "mm/dd/yy")
similar to your
fmtDate = Format(Date, "mmm-yy")
(A difference is that I don't have anything like "Dim fmtDate As String
"). But what do you mean by a Format() method "hidden away in a little
corner" of the workbook? Or, if anyone else knows what else could be
causing the problem, I would appreciate the assistance
John





--------------------


When I compile the code I get the if highlights *Format* and I get the
following error


Compile Error:
 
After a couple of weeks I finally found my solution from this thread. I had a macro named "Format" and my export was getting the error due to the reference. When I renamed my macro to "Reformat" the code worked perfectly. Thanks!
 
Back
Top