Invalid Qualifier

30percent

Board Regular
Joined
May 5, 2011
Messages
101
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!
 

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
35,504
Office Version
2010
Platform
Windows
Which line of code was highlighted when the error occurred?

Also, do you have procedures named get_Minus_Day and get_SessionDate?
 
Last edited:

30percent

Board Regular
Joined
May 5, 2011
Messages
101
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
 

Forum statistics

Threads
1,081,749
Messages
5,361,064
Members
400,611
Latest member
ThebigG

Some videos you may like

This Week's Hot Topics

  • populate from drop list with multiple tables
    Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
  • Find list of words from sheet2 in sheet1 before a comma and extract text vba
    Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
  • Dynamic Formula entry - VBA code sought
    Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...
  • Listbox Header
    Have a named range called "AccidentsHeader" Within my code I have: [CODE]Private Sub CommandButton1_Click() ListBox1.RowSource =...
  • Complex Heat Map using conditional formatting
    Good day excel world. I have a concern. Below link have a list of countries that carries each country unique data. [URL...
  • Conditional formatting
    Hi good morning, hope you can help me please, I have cells P4:P54 and if this cell is equal to 1 then i want row O to say "Fully Utilised" and to...
Top