#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Date Format

Hi,

Please explain what is wrong with this:

Dim sMonth as string

smonth = format(Sheets("ChartsP").Range("a1").Value, "mmm-yy")

I am getting an error message: "Wrong number of arguments or invalid
property assignment

TIA

Dave
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Date Format

The line looks OK. Is that all you have..Where is this code placed?

If this post helps click Yes
---------------
Jacob Skaria


"Risky Dave" wrote:

Hi,

Please explain what is wrong with this:

Dim sMonth as string

smonth = format(Sheets("ChartsP").Range("a1").Value, "mmm-yy")

I am getting an error message: "Wrong number of arguments or invalid
property assignment

TIA

Dave

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 161
Default Date Format

Jacob,

Thanks for the quick reply. This is the start of the code (the whole things
is about 80 lines, so I won't post it all here):

Dim sMonth As String
Dim sLastEntry As String
Dim lNetScore As Long
Dim arrSum As Variant
Dim lriskcount As Long
Dim lRowNum As Long

Application.ScreenUpdating = False

' check if it is the same month
Set rCurrentCell = Sheets("ChartsP").Range("n2")
Do
Set rCurrentCell = rCurrentCell.Offset(1, 0)
Loop Until rCurrentCell.Value = ""
Set rCurrentCell = rCurrentCell.Offset(-1, 0)
sMonth = Sheets("ChartsP").Range("a1").Value
Do
sLastEntry = rCurrentCell.Value
If sMonth = sLastEntry Then
' do stuff here
Loop
Application.ScreenUpdating = True
End Sub

What I am trying to do is read the value of a specified cell that contains
Today() and format it as "mmm-yy" to a string variable (sMonth). Then I want
to compare sMonth with another string variable (sLastEntry) which gets it
content from a different cell and is formatted in the same way.

Hope this makes sense

Dave

"Jacob Skaria" wrote:

The line looks OK. Is that all you have..Where is this code placed?

If this post helps click Yes
---------------
Jacob Skaria


"Risky Dave" wrote:

Hi,

Please explain what is wrong with this:

Dim sMonth as string

smonth = format(Sheets("ChartsP").Range("a1").Value, "mmm-yy")

I am getting an error message: "Wrong number of arguments or invalid
property assignment

TIA

Dave

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Date Format

You dont need to loop if you are trying to get the last entry in Col N

'Try (if both cells are in excel date format)
If Sheets("ChartsP").Cells(Rows.Count, "N").End(xlUp).Value = _
Sheets("ChartsP").Range("a1").Value Then

End If


If this post helps click Yes
---------------
Jacob Skaria


"Risky Dave" wrote:

Jacob,

Thanks for the quick reply. This is the start of the code (the whole things
is about 80 lines, so I won't post it all here):

Dim sMonth As String
Dim sLastEntry As String
Dim lNetScore As Long
Dim arrSum As Variant
Dim lriskcount As Long
Dim lRowNum As Long

Application.ScreenUpdating = False

' check if it is the same month
Set rCurrentCell = Sheets("ChartsP").Range("n2")
Do
Set rCurrentCell = rCurrentCell.Offset(1, 0)
Loop Until rCurrentCell.Value = ""
Set rCurrentCell = rCurrentCell.Offset(-1, 0)
sMonth = Sheets("ChartsP").Range("a1").Value
Do
sLastEntry = rCurrentCell.Value
If sMonth = sLastEntry Then
' do stuff here
Loop
Application.ScreenUpdating = True
End Sub

What I am trying to do is read the value of a specified cell that contains
Today() and format it as "mmm-yy" to a string variable (sMonth). Then I want
to compare sMonth with another string variable (sLastEntry) which gets it
content from a different cell and is formatted in the same way.

Hope this makes sense

Dave

"Jacob Skaria" wrote:

The line looks OK. Is that all you have..Where is this code placed?

If this post helps click Yes
---------------
Jacob Skaria


"Risky Dave" wrote:

Hi,

Please explain what is wrong with this:

Dim sMonth as string

smonth = format(Sheets("ChartsP").Range("a1").Value, "mmm-yy")

I am getting an error message: "Wrong number of arguments or invalid
property assignment

TIA

Dave

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
permanent conversion of 1904 date format to 1900 date format Jos Excel Worksheet Functions 4 November 26th 15 02:48 PM
convert serial date format to normal date format Flagworld Excel Discussion (Misc queries) 3 September 23rd 08 01:32 PM
Excel 2000 date format cannot be set to Australian date format Brian Jones Excel Discussion (Misc queries) 1 March 30th 05 06:03 AM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM
Change a date in text format xx.xx.20xx to a recognised date format concatenator Excel Programming 1 November 24th 03 11:33 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"