Log in

View Full Version : Trouble when using the weekday function



sarahuff
10-03-2024, 04:51 PM
Hello,
When using the weekday function, I got a message error about incompatible types:


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

What does this error means? How can I solve it? Thanks

arnelgp
10-03-2024, 05:58 PM
change it to:


I = 1


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