Date Format

  • Thread starter Thread starter Risky Dave
  • Start date Start date
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
 
The line looks OK. Is that all you have..Where is this code placed?

If this post helps click Yes
 
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
 
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
 
Back
Top