PDA

View Full Version : Weekday function error



jhd
02-25-2012, 11:25 AM
Hi, I'm having some trouble when using the Weekday function, it returns me incompatible types error.


Sub MIX_FillDays(howmanydays As Integer, ByVal monthnumber As Integer, ByVal yearnumber As Integer)

Dim fullday As String
Dim dayoftheweek As Integer
Dim dayname As String
Dim ran As String

I = 1

Sheets("taks1").Select
Do Until I = howmanydays
fullday = I & "/" & monthnumber & "/" & yearnumber
dayoftheweek = Weekday(fullday) '*** error happens here! ***
Call MIX_TranslateWeekDayName(dayoftheweek,dayname)
ran = "I" & I + 3
Range(ran).Value = dayname
I = I + 1
Loop


End Sub
Any idea about what can be wrong?

mikerickson
02-25-2012, 12:26 PM
Weekday requires a Date as its argument. That code is giving it a String. Try
dayoftheweek = Weekday(DateValue(fullday))