Invalid Qualifier

30percent

Board Regular
Joined
May 5, 2011
Messages
123
Office Version
  1. 2016
Platform
  1. Windows
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!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Which line of code was highlighted when the error occurred?

Also, do you have procedures named get_Minus_Day and get_SessionDate?
 
Last edited:
Upvote 0
this line of code was highlighted:

Code:
[COLOR=#333333]Sub update_MTD()[/COLOR]

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
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top