Results 1 to 3 of 3

Thread: Invalid Qualifier
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    May 2011
    Posts
    101
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Invalid Qualifier

    Hi,

    I have the following code.
    However, it would not run - I got the following error message:

    Compile Error:
    Invalid qualifier.

    Wonder if someone could point what the error is.

    Thank you!
    Code:
    Sub update_MTD()
    Dim minus_day As Integer, sessionDate As String, current_Month As Integer, previous_Month As Integer
    
    
    minus_day = get_Minus_Day()
    sessionDate = get_SessionDate(minus_day)
    current_Month = Month(sessionDate)
    previous_Month = current_Month - 1
    
    
    Dim startRow_current As Long, endRow_current As Long, startRow_prev As Long, endRow_prev As Long
    With ThisWorkbook.Worksheets("Totals")
        startRow_current = .Range("A:A").Find(what:="current_Month", after:=ThisWorkbook.Worksheets("Totals").Range("A1")).Row
        endRow_current = .Range("A:A").Find(what:="current_Month", after:=ThisWorkbook.Worksheets("Totals").Range("A1"), searchdirection:=xlPrevious).Row
        startRow_prev = .Range("A:A").Find(what:="previous_Month", after:=ThisWorkbook.Worksheets("Totals").Range("A1")).Row
        endRow_prev = .Range("A:A").Find(what:="previous_Month", after:=ThisWorkbook.Worksheets("Totals").Range("A1"), searchdirection:=xlPrevious).Row
    End With
    
    
    Set rng_Current_MTD = ThisWorkbook.Worksheets("Totals").Range("C" & startRow_current.Row, "C" & endRow_current.Row)
    
    
    Current_MTD = WorksheetFunction.Sum(rng_Current_MTD)
    
    
    End Sub
    you!

  2. #2
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    35,244
    Post Thanks / Like
    Mentioned
    92 Post(s)
    Tagged
    33 Thread(s)

    Default Re: Invalid Qualifier

    Which line of code was highlighted when the error occurred?

    Also, do you have procedures named get_Minus_Day and get_SessionDate?
    Last edited by Rick Rothstein; Sep 16th, 2019 at 06:50 PM.
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  3. #3
    Board Regular
    Join Date
    May 2011
    Posts
    101
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Invalid Qualifier

    this line of code was highlighted:

    Code:
    Sub update_MTD()
    Code:
    Dim minus_day As Integer
    
    today = get_today("weekday")
    
    
    Select Case today
    Case 2, 3, 4, 5
        minus_day = 0
    Case 1
        minus_day = 2
    End Select
    
    
    get_Minus_Day = minus_day
    
    
    
    
    End Function
    
    
    Public Function get_SessionDate(ByVal minus_day As Integer)
    
    
    Dim session_Date As String
    Dim sessionYear As String
    Dim sessionDay As String
    Dim sessionMonth As String
    
    
    thisDate = get_today("today")
    
    
    sessionYear = Year(thisDate - minus_day)
    
    
    If (Day(thisDate - minus_day)) < 10 Then
        sessionDay = "0" & CStr(Day(Date - minus_day))
    Else
        sessionDay = CStr(Day(thisDate - minus_day))
    End If
    
    
    If (Month(thisDate - minus_day)) < 10 Then
        sessionMonth = "0" & CStr(Month(thisDate - minus_day))
    Else
        sessionMonth = CStr(Month(thisDate - minus_day))
    End If
    
    
    session_Date = sessionMonth & "-" & sessionDay & "-" & sessionYear
    
    
    get_SessionDate = session_Date
    
    
    End Function

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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