Hello - I'm sure this has been covered somewhere but I've been searching for days with no success. Sharing the spreadsheet will require a lot of work to allow me to release it so hopefully I've been clear enough with my notes below.
First the problem - I have a Macro that performs a COUNTIFS for a number of things including a Greater Than Or Equal To date and a Less Than OR Equal To date. I am based in North America and this works perfectly for any other users in North America. UK based users return no matches unless I comment out the Date filters in the COUNTIFS.
Background:
- My Excel file needs to import source data (from .xlsx) that does not have a consistent file naming convention so I have a "file picker" that allows the user to select the proper source file and then the VBA script will copy the data and paste it to a Worksheet (InputSheet). Clearing out data with minimal user interaction between each use of the spreadsheet is critical so I have not looked at a "Data -> Get Data" import.
- The dates in the source file are in format yyyy-mm-dd hh:mm so I have a formula column in the InputSheet where I use "=INT(B2)" to get it into a date format
- Created a second formula column, for UK date format, in InputSheet where I use "=INT(B2) to get it into a date format
- Users in US set the date range for the report by typing in a start date and end date (in UserInputSheet) in format mm/dd/yyyy
- Users in UK set the date range for the report by typing in a start date and end date (in UserInputSheet) in format dd/mm/yyyy
- Table Data and a Chart are presented in OutputSheet
Sample of the CountIfs for US (part of a For Loop):
OutputSheet.Cells(6, column).Value = Application.WorksheetFunction.CountIfs( _
InputSheet.Range(InputSheet.Cells(2, 3), InputSheet.Cells(Rows, 3)), Worksheets("OutputSheet").Cells(3, Column), _
InputSheet.Range(InputSheet.Cells(2, 5), InputSheet.Cells(Rows, 5)), Worksheets("OutputSheet").Cells(6, 1), _
InputSheet.Range(InputSheet.Cells(2, 10), InputSheet.Cells(Rows, 10)), ">=" & UserInputSheet.Range("B1"), _
InputSheet.Range(InputSheet.Cells(2, 10), InputSheet.Cells(Rows, 10)), "<=" & UserInputSheet.Range("B2"))
Sample of the CountIfs for US (part of a For Loop):
OutputSheet.Cells(6, column).Value = Application.WorksheetFunction.CountIfs( _
InputSheet.Range(InputSheet.Cells(2, 3), InputSheet.Cells(Rows, 3)), Worksheets("OutputSheet").Cells(3, Column), _
InputSheet.Range(InputSheet.Cells(2, 5), InputSheet.Cells(Rows, 5)), Worksheets("OutputSheet").Cells(6, 1), _
InputSheet.Range(InputSheet.Cells(2, 11), InputSheet.Cells(Rows, 11)), ">=" & UserInputSheet.Range("E1"), _
InputSheet.Range(InputSheet.Cells(2, 11), InputSheet.Cells(Rows, 11)), "<=" & UserInputSheet.Range("E2"))
Each of the above are their own Sub to avoid any issues. They are identical other than the column I'm looking at for the date of the source data and the cells I'm looking at for the date range.
Dates in UserInputSheet are Date format 2012-03-14 "English United States"
Dates in US Calculated column in InputSheetare Date format mm/dd/yyyy "English United States"
Dates in UK Calculated column in InputSheetare Date format dd/mm/yyyy "English United Kingdom"
If I set my PC to English United Kingdom in the Control Panel Region it makes no differerence. The US script still works and the UK script still fails.
My guess right now is that the INT formula isn't ideal.
Any help would be greatly appreciated!
Bookmarks