Consulting

Results 1 to 2 of 2

Thread: Trouble when using the weekday function

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Oct 2024
    Posts
    1
    Location

    Trouble when using the weekday function

    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
    Last edited by georgiboy; 10-04-2024 at 04:45 AM. Reason: Added code tags
    .

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •