Capture Text in a Range

MrDB4Excel

Active Member
Joined
Jan 29, 2004
Messages
348
Office Version
  1. 2013
Platform
  1. Windows
I have searched through dozens of web pages for answers to the following but to no avail.
In this Excel sheet, you see a list of months in column L with corresponding values in column M.
Next, in column N are running totals but because April is not finished then cell N6 is blank (does not yet have the formula to add M6 to N5).
Formulas are not yet inserted in N6 through N14 because elsewhere I am getting the value in column N that represents the total from the previous full months prior to the current month of April in this scenario.
So what formula can be inserted in column N that would only total all previous full months that have expired?
In addition, I also need to get a comma delineated list of the months that appear in column P. You can see I have formulas in P3 through P14.
In column Q you can see my attempts at getting this list of months prior to the current month but they contain commas that represent the empty cells. I do not want these commas to show.
Perhaps I am not creating a good working formula in the first place.

I would so appreciate some advice on how to solve this.

Bogus RangeCapture.xlsx
LMNOPQ
1April
2Each Month's Total
3January7,588.007,588.00JanuaryJanuary, February, March, , , , , , , , , ,
4February7,663.0015,251.00FebruaryJanuaryFebruaryMarch
5March11,543.0026,794.00MarchJanuary, February, March, , , , , , , , ,
6April1,520.00 
7May0.00 
8June0.00 
9July0.00 
10August0.00 
11September0.00 
12October0.00 
13November0.00 
14December0.00 
Sheet1
Cell Formulas
RangeFormula
L1L1=TEXT(TODAY(),"MMMM")
N3N3=M3
N4:N5N4=SUM(N3+M4)
Q3Q3=CONCATENATE("January, ","February, ","March, ",", ",", ",", ",", ",", ",", ",", ",", ",", ")
Q4Q4=CONCATENATE(P3,P4,P5,P6,P7,P8,P9,P10,P11,P12,P13,P14)
Q5Q5=P3&", "&P4&", "&P5&", "&P6&", "&P7&", "&P8&", "&P9&", "&P10&", "&P11&", "&P12&", "&P13&", "&P14
P3:P14P3=IFERROR(INDEX(L3:L14,MATCH(N3,N3:N14,0)),"")
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
For col Q you can use
Excel Formula:
=SUBSTITUTE(TRIM(P3&" "&P4&" "&P5&" "&P6&" "&P7&" "&P8&" "&P9&" "&P10&" "&P11&" "&P12&" "&P13&" "&P14)," ",", ")
Are you happy to change the months in col L into real dates & just display them as Months?
 
Upvote 0
For col Q you can use
Excel Formula:
=SUBSTITUTE(TRIM(P3&" "&P4&" "&P5&" "&P6&" "&P7&" "&P8&" "&P9&" "&P10&" "&P11&" "&P12&" "&P13&" "&P14)," ",", ")
Are you happy to change the months in col L into real dates & just display them as Months?
Fluff, thank you so much, this is perfect. I changed the months to the custom date "mmmm", added your formula to a cell, and voila. It only shows January, February, March.
Exactly what I was looking to do.
About the other cells in column N: N6 thru N14 that do not have formulas. Is this at all possible to only get a sum if the month is completed?
 
Upvote 0
You need to Change L1 to an actual date & than use this.
Note I have also change the formula in col P
+Fluff 1.xlsm
LMNOPQ
104/04/2022
2Each Month's Total
3January75887588JanuaryJanuary, February, March
4February766315251FebruaryJanuary, February, March
5March1154326794MarchJanuary, February, March
6April1520  
7May0  
8June0  
9July0  
10August0  
11September0  
12October0  
13November0  
14December0  
Main
Cell Formulas
RangeFormula
L1L1=TODAY()
Q3:Q5Q3=SUBSTITUTE(TRIM(P1&" "&P2&" "&P3&" "&P4&" "&P5&" "&P6&" "&P7&" "&P8&" "&P9&" "&P10&" "&P11&" "&P12)," ",", ")
N3:N14N3=IF(DATEVALUE("1/"&L3)<EOMONTH($L$1,-1),SUM(M$3:M3),"")
P3:P14P3=IF(N3="","",L3)
 
Upvote 0
Solution
You need to Change L1 to an actual date & than use this.
Note I have also change the formula in col P
+Fluff 1.xlsm
LMNOPQ
104/04/2022
2Each Month's Total
3January75887588JanuaryJanuary, February, March
4February766315251FebruaryJanuary, February, March
5March1154326794MarchJanuary, February, March
6April1520  
7May0  
8June0  
9July0  
10August0  
11September0  
12October0  
13November0  
14December0  
Main
Cell Formulas
RangeFormula
L1L1=TODAY()
Q3:Q5Q3=SUBSTITUTE(TRIM(P1&" "&P2&" "&P3&" "&P4&" "&P5&" "&P6&" "&P7&" "&P8&" "&P9&" "&P10&" "&P11&" "&P12)," ",", ")
N3:N14N3=IF(DATEVALUE("1/"&L3)<EOMONTH($L$1,-1),SUM(M$3:M3),"")
P3:P14P3=IF(N3="","",L3)
All good except your formula =IF(DATEVALUE("1/"&L3)<EOMONTH($L$1,-1),SUM(M$3:M3),"") in N3 returns #VALUE!
I left my L1 to be =TEXT(TODAY(),"MMM")
Changed all in P3 to P14 to =IF(N3="","",L3), =IF(N4="","",L4), etcetera thru to P14: =IF(N14="","",L14)
 
Upvote 0
You need to change that to a real date. You can change the cell format if desired.
Okay, after I did that now my formula in Cell N2: =XLOOKUP(L1,$L$3:$L$23,$M$3:$M$23,0) returns a #N/A
I changed L1 to be =TODAY() and format changed in custom to mmm
Now your formula: =IF(DATEVALUE("1/"&L3)<EOMONTH($L$1,-1),SUM(M$3:M3),"") works fine.
Looking at this formula gives me a headache, meaning I don't understand how it works.
So what causes cell N6 to be blank?
 
Upvote 0
This part DATEVALUE("1/"&L3) converts the month name in L3 into an actual date & if that date is less than the end of last month it runs the Sum otherwise it returns ""

now my formula in Cell N2:
In the data you posted there is no formula in N2
 
Upvote 0
This part DATEVALUE("1/"&L3) converts the month name in L3 into an actual date & if that date is less than the end of last month it runs the Sum otherwise it returns ""


In the data you posted there is no formula in N2
Here you go, this is the non-bogus file.
2022MonthlySubTotals.xlsm
HIJKLMNOPQR
128,314.00Current MonthAprApr4/4/202214:27:53Months Previous to Current MonthMar26,794.00
2ÇYear To Date Grand TotalÈ2022 Annual TotalsEach Month's Total#N/A26,794.00
3Kaufland Total This Month0.001KauflandJan7,588.007,588.00JanJan, Feb, Mar
4Tesco Total This Month0.002TescoFeb7,663.0015,251.00Feb
5Lidl Total This Month0.003LidlMar11,543.0026,794.00Mar
6Penny Market Total This Month0.004Penny MarketApr1,520.00  
7dm Total This Month0.005dmMay0.00  
8Obchod Dyleň Total This Month0.006Obchod DyleňJun0.00  
9Biller Total This Month0.007BillerJul0.00  
10SubTotal0.008OrionAug0.00  
119PepcoSep0.00  
12Running Total0.00Oct0.00  
13Non-Product Purchase Total0.00Nov0.00  
14Dec0.00  
December
Cell Formulas
RangeFormula
H1H1=SUM(November!H1,December!G1)
L1,N1L1=TODAY()
M1M1=L1
O1O1=NOW()
Q1Q1=TEXT(EOMONTH(TODAY(),-1),"mmm")
R1R1=MAX(N3:N14)
N2N2=XLOOKUP(L1,$L$3:$L$23,$M$3:$M$23,0)
M3M3=January!$G$1
N3:N14N3=IF(DATEVALUE("1/"&L3)<EOMONTH($L$1,-1),SUM(M$3:M3),"")
M4M4=February!$G$1
M5M5=March!$G$1
M6M6=April!$G$1
M7M7=May!$G$1
M8M8=June!$G$1
M9M9=July!$G$1
M10M10=August!$G$1
M11M11=September!$G$1
M12M12=October!$G$1
M13M13=November!$G$1
M14M14=December!$G$1
Q3Q3=SUBSTITUTE(TRIM(P3&" "&P4&" "&P5&" "&P6&" "&P7&" "&P8&" "&P9&" "&P10&" "&P11&" "&P12&" "&P13&" "&P14)," ",", ")
I3:I9I3=SUMIF($B$3:$B$55,K3,$E$3:$E$55)
I10I10=SUM(I3:I8)
I12I12=G1
I13I13=SUM(I12-I10)
P2P2=XLOOKUP(Q1,$L$3:$L$23,$N$3:$N$23,0)
P3:P14P3=IF(N3="","",L3)
 
Upvote 0
Ok, how about
Excel Formula:
=XLOOKUP(TEXT(L1,"mmm"),$L$3:$L$23,$M$3:$M$23,0)
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,208
Members
452,618
Latest member
Tam84

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