Date Format

R

Risky Dave

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
 
J

Jacob Skaria

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

If this post helps click Yes
 
R

Risky Dave

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
 
J

Jacob Skaria

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
 

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

Similar Threads

Check that date exists 1
Date Format 7
Date Format - simple question 1
Copy Array to Array, how to and should I? 13
strange behaviour 1
Changing Query Defs in VBA 44
Workbook reminder 0
Date format. 2

Top