Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6017541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:08:36+00:00 2026-05-23T03:08:36+00:00

The below code is producing the wrong result. On the work sheet we are

  • 0

The below code is producing the wrong result. On the work sheet we are using two identical date formats (dd/mm/yyyy) however when the following is run it appears to be trying to interpret the rev_date as American date format, whilst interpreting grid_date as the correct UK format.

We tested this by changing the rev_date on the worksheet to the American format, in which case it produces the correct result.

Any ideas why we would need to change rev_date to an American format, we would prefer to keep it as UK?

Public Function GRIDSALES(rev_date As Date, grid_date As Date) As Double


  Dim Order_Type As Range
  Dim Final_Price As Range
  Dim PaidAlt As Range
  Dim Excl_Rev As Range
  Dim PAmount1 As Range
  Dim PMethod1 As Range
  Dim PAmount2 As Range
  Dim PayDate2 As Range
  Dim PMethod2 As Range
  Dim Vstatus As Range
  Dim Team As Range

  Application.Volatile (True)

  Set Order_Type = Sheets("KRONOS").Range("$D:$D")
  Set Final_Price = Sheets("KRONOS").Range("$H:$H")
  Set PaidAlt = Sheets("KRONOS").Range("$I:$I")
  Set Excl_Rev = Sheets("KRONOS").Range("$K:$K")
  Set PAmount1 = Sheets("KRONOS").Range("$O:$O")
  Set First_PD = Sheets("KRONOS").Range("$Q:$Q")
  Set PMethod1 = Sheets("KRONOS").Range("$R:$R")
  Set PAmount2 = Sheets("KRONOS").Range("$T:$T")
  Set PayDate2 = Sheets("KRONOS").Range("$V:$V")
  Set PMethod2 = Sheets("KRONOS").Range("$W:$W")
  Set Vstatus = Sheets("KRONOS").Range("$DL:$DL")
  Set Team = Sheets("KRONOS").Range("$DO:$DO")

            GRIDSALES1 = Application.WorksheetFunction.SumIfs( _
            PAmount1 _
            , Team, "<>9" _
            , Vstatus, "<>rejected", Vstatus, "<>unverified" _
            , Excl_Rev, "<>1" _
            , PMethod1, "<>Credit" _
            , PMethod1, "<>Amendment" _
            , PMethod1, "<>Pre-paid" _
            , First_PD, ">=" & rev_date _
            , First_PD, "<=" & Application.WorksheetFunction.EoMonth(grid_date, 0))

            GRIDSALES = GRIDSALES1

End Function

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T03:08:36+00:00Added an answer on May 23, 2026 at 3:08 am

    When you do this

    First_PD, ">=" & rev_date
    

    and this

    First_PD, "<=" & Application.WorksheetFunction.EoMonth(grid_date, 0))
    

    you are implicitly coercing two variables of type Date (rev_date and grid_date) into type String. Implicit coercion is bad practice, and this is a pretty typical example why it’s bad practice. Your dates should be explicitly converted to String using an unambiguous format, e.g.

    First_PD, ">=" & Format$(rev_date,"dd mmm yyyy") 
    

    In this format, 12 Jan 2011 can’t be confused with 1 Dec 2011.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.