Very Strange Error when using Format()

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
 
P

Pete

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
 
J

JE McGimpsey

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

Or your own Format method?
 
W

wjoc1

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
 
W

wjoc1

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
 
J

John Pierce

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:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top