Substracting French entered dates when my system is in english

Blanchetdb

Board Regular
Joined
Jul 31, 2018
Messages
153
Office Version
  1. 2016
Platform
  1. Windows
Hi

I am using an English system...

My workbook has a number of worksheets, English and French. I am able to calculate the difference between two dates in the English worksheets as the date is entered in an English format (April 1, 2022)....
the formula used is =D15-AH4 which is April 1, 2022 minus January 1, 2021.
The D15 cell is in a Text format which is needed as it copies to a Word document using another macro I have within my workbook
This process works

My French worksheets requires the person to enter the date in a French format (1 janvier, 2022) as Text in cell D15
the formula is the same and the cells are both formatted as "Date / 1 janvier, 2022 - French(Canada)"

the issue is that I get a #Value error due to the dates being written in French

I tested the cells by inserting the English format and it works but as soon as the date is entered in French using the month format

is there a way around that?
thanks
 
What part of the formula yielded the error? Try Excel's Formula Evaluate!

You are using 4 characters for abbrev. I edited the table and formula.
Check help for Lookup. The data must be sorted Months Alpha.
I edited the formula and added the lookup table; check the data.
N.B Mai is 3 characters, note the ",". Are 3 character abbrev acceptable?
You can name the Lookup information see array in F15. I named the array aL for the formula in H15.

Date and Time.xlsm
ABCDEFGH
1Month AlphaMonth #French month text
2aout8
3avri4
4dece12
5fevr2
6janv1
7juil7
8juin6
9mai,5
10mars3
11nove11
12octo10
13sept9
141-Apr-22Date455
1524 mars, 2022Text447447447
161 janvier, 2021Text000
1715 mai, 2021Text134134134
24b
Cell Formulas
RangeFormula
F14F14=D14-AH4
F15:F17F15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),{"aout",8;"avri",4;"dece",12;"fevr",2;"janv",1;"juil",7;"juin",6;"mai,",5;"mars",3;"nove",11;"octo",10;"sept",9}),LEFT(D15,2))-AH$4
G15:G17G15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),$A$2:$B$13),LEFT(D15,2))-AH$4
H15:H17H15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),aL),LEFT(D15,2))-AH$4
 
Upvote 0
Solution

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
N.B. It is a good idea to show the Excel version that you use in your profile.
XLookup is available in 365 and probably 2021.

You could use VLookup or XLookup with full month names.
Edit the formulas and extract the relevant text for month and refer to the relevant data for the lookup.
Ensure the spelling in the lookup information is correct.

Date and Time.xlsm
ABCDEFGHIJ
1Month AlphaMonth #French month text
2aout8janvier1
3avri4février2
4dece12mars3
5fevr2avril4
6janv1mai5
7juil7juin6
8juin6juillet7
9mai,5août8
10mars3septembre9
11nove11octobre10
12octo10novembre11
13sept9décembre12
14
1524 mars, 2022Text447447447447447
161 janvier, 2021Text00000
1715 mai, 2021Text134134134134134
18
24b
Cell Formulas
RangeFormula
F15:F17F15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),{"aout",8;"avri",4;"dece",12;"fevr",2;"janv",1;"juil",7;"juin",6;"mai,",5;"mars",3;"nove",11;"octo",10;"sept",9}),LEFT(D15,2))-AH$4
G15:G17G15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),$A$2:$B$13),LEFT(D15,2))-AH$4
H15:H17H15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),aL),LEFT(D15,2))-AH$4
I15:I17I15=DATE(RIGHT(D15,4),XLOOKUP(MID(D15,FIND(" ",D15)+1,FIND(",",D15)-1-FIND(" ",D15)),$D$2:$D$13,$E$2:$E$13),LEFT(D15,2))-AH$4
J15:J17J15=DATE(RIGHT(D15,4),VLOOKUP(MID(D15,FIND(" ",D15)+1,FIND(",",D15)-1-FIND(" ",D15)),$D$2:$E$13,2,0),LEFT(D15,2))-AH$4
 
Upvote 0
What part of the formula yielded the error? Try Excel's Formula Evaluate!

You are using 4 characters for abbrev. I edited the table and formula.
Check help for Lookup. The data must be sorted Months Alpha.
I edited the formula and added the lookup table; check the data.
N.B Mai is 3 characters, note the ",". Are 3 character abbrev acceptable?
You can name the Lookup information see array in F15. I named the array aL for the formula in H15.

Date and Time.xlsm
ABCDEFGH
1Month AlphaMonth #French month text
2aout8
3avri4
4dece12
5fevr2
6janv1
7juil7
8juin6
9mai,5
10mars3
11nove11
12octo10
13sept9
141-Apr-22Date455
1524 mars, 2022Text447447447
161 janvier, 2021Text000
1715 mai, 2021Text134134134
24b
Cell Formulas
RangeFormula
F14F14=D14-AH4
F15:F17F15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),{"aout",8;"avri",4;"dece",12;"fevr",2;"janv",1;"juil",7;"juin",6;"mai,",5;"mars",3;"nove",11;"octo",10;"sept",9}),LEFT(D15,2))-AH$4
G15:G17G15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),$A$2:$B$13),LEFT(D15,2))-AH$4
H15:H17H15=DATE(RIGHT(D15,4),LOOKUP(MID(D15,FIND(" ",D15)+1,4),aL),LEFT(D15,2))-AH$4
it works !!!!

again... thank you VERY much for all your help
 
Upvote 0

Forum statistics

Threads
1,214,560
Messages
6,120,222
Members
448,951
Latest member
jennlynn

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