I have a macro that I am using that is 5+ years old, I first started using it in 32bit Excel 2007 but I no longer use Excel 2007 anymore, instead I use Excel 2013 and this macro no longer works correctly...
- Run it in Excel 2007 with regional settings set to United Kingdom or United States = Works perfectly
- Run it in Excel 2010 or Excel 2013 with regional settings set to United Kingdom = Doesn't work
- Run it in Excel 2010 or Excel 2013 with regional settings set to United States = Works perfectly
Problem is, I'm British so my regional settings are set to United Kingdom.
The main question is...
How can I make my macro compatible so that it can either manage with any of the regional settings OR how can I get the macro to only work with United Kingdom regional settings (date)...
The macro is supposed to match two columns using autofilters to find the matched rows and then export data from one sheet to a different sheet. I've included a sheet called "RUSHEET (CORRECT)" that has what the output should look like.
Download: https://www.dropbox.com/s/8edbk8rcp3qumfd/example.xlsm?dl=1
The macro in question is:
Sub CROSSIMPORT()
'Optimize'
With Application
.ScreenUpdating = False
.EnableEvents = False
.Calculation = xlCalculationManual
.DisplayAlerts = False
End With
Dim wsData As Worksheet: Set wsData = Sheets("RASHEET")
Dim wsList As Worksheet: Set wsList = Sheets("RUSHEET")
'Loads data into the array from wsList, column A to column E
'In the beginning, columns B through E may be empty, that is fine
Dim arrListVal As Variant: arrListVal = wsList.Range("b2", wsList.Cells(Rows.Count, "b").End(xlUp).Offset(0, 43)).Value
Dim arrIndex As Long
Dim rngFound As Range
'Set Range for columns to check (both columns)
With Intersect(wsData.UsedRange, wsData.Columns("B:C"))
'UBound(arrListVal, 1) is the upper bound of the first dimension of the array
'In other words, its the number of rows
'We'll use arrIndex to go through each row
'arrIndex starts at 1 because that's the LBound, we already set the array to go from A5 though, so no worries there
For arrIndex = 1 To UBound(arrListVal, 1)
'Turn AutoFilter off, test
If .AutoFilter Then .AutoFilter
'Filter first array (matching array column 1)
.AutoFilter 1, arrListVal(arrIndex, 1)
'Filter second array (matching array column 2)
.AutoFilter 2, arrListVal(arrIndex, 2)
On Error Resume Next
'arrListVal(arrIndex, 1) = row arrIndex in column 1 of the array
'Attempts to find that value in wsData, column A
Set rngFound = .Offset(1).Resize(.Rows.Count - 1).SpecialCells(xlCellTypeVisible)
'Set rngFound = wsData.Columns("B").Find(What:=arrListVal(arrIndex, 1), LookAt:=xlWhole)
'If it found something, then rngFound will not be nothing
If Not rngFound Is Nothing Then
'Found something, fills the other columns of the array
arrListVal(arrIndex, 36) = wsData.Range("P" & rngFound.Row).Value 'wsList column C should be wsData column I
arrListVal(arrIndex, 37) = wsData.Range("G" & rngFound.Row).Value 'wsList column D should be wsData column O
arrListVal(arrIndex, 38) = wsData.Range("E" & rngFound.Row).Value 'wsList column E should be wsData column K
arrListVal(arrIndex, 39) = wsData.Range("F" & rngFound.Row).Value
arrListVal(arrIndex, 40) = wsData.Range("X" & rngFound.Row).Value
arrListVal(arrIndex, 43) = wsData.Range("AF" & rngFound.Row).Value
arrListVal(arrIndex, 44) = wsData.Range("AG" & rngFound.Row).Value
'Sets rngFound back to nothing in order to continue the loop through the array
Set rngFound = Nothing
Else
End If
Next arrIndex
'Turning Filter Off
.AutoFilter
End With
wsList.Range("B2").Resize(UBound(arrListVal, 1), UBound(arrListVal, 2)).Value = arrListVal
'De-Optimize'
With Application
.ScreenUpdating = True
.EnableEvents = True
.Calculation = xlCalculationAutomatic
.DisplayAlerts = True
End With
End Sub

