ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Very Strange Error when using Format() (https://www.excelbanter.com/excel-programming/342334-very-strange-error-when-using-format.html)

wjoc1[_5_]

Very Strange Error when using Format()
 

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

--
wjoc
-----------------------------------------------------------------------
wjoc1's Profile: http://www.excelforum.com/member.php...fo&userid=1528
View this thread: http://www.excelforum.com/showthread.php?threadid=47469


Pete[_22_]

Very Strange Error when using Format()
 
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

"wjoc1" wrote in
message ...

Guys,

This is a new one to me anyways. I was wondering if anyone could shed
any light on it for me. This has to be the simplest piece of vb code
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 excel
different workbook this works fine... as it should.

Thanks,
Liam


--
wjoc1
------------------------------------------------------------------------
wjoc1's Profile:
http://www.excelforum.com/member.php...o&userid=15281
View this thread: http://www.excelforum.com/showthread...hreadid=474691




JE McGimpsey

Very Strange Error when using Format()
 
Do you have a global or procedure variable named Date that's overriding
the Date method?

Or your own Format method?

In article ,
wjoc1 wrote:

This is a new one to me anyways. I was wondering if anyone could shed
any light on it for me. This has to be the simplest piece of vb code
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 excel
different workbook this works fine... as it should.


wjoc1[_6_]

Very Strange Error when using Format()
 

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

--
wjoc
-----------------------------------------------------------------------
wjoc1's Profile: http://www.excelforum.com/member.php...fo&userid=1528
View this thread: http://www.excelforum.com/showthread.php?threadid=47469


wjoc1[_7_]

Very Strange Error when using Format()
 

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


--
wjoc1
------------------------------------------------------------------------
wjoc1's Profile: http://www.excelforum.com/member.php...o&userid=15281
View this thread: http://www.excelforum.com/showthread...hreadid=474691


John Pierce

Very Strange Error when using Format()
 
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:



All times are GMT +1. The time now is 07:34 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com