Need Help on making a list of words based on the below requirement

kriszpm

New Member
Joined
Dec 19, 2018
Messages
6
-----------------------------------------------------------------------------------------------------------------------------------------------------------

Example String: "calculating cumulative stats for quarters"

-----------------------------------------------------------------------------------------------------------------------------------------------------------

The outcome should be in the below format:


1 Word List: (No Duplicates)
calculating
cumulative
stats
for
quarters



2 Words List: (The 2 Words should be only in sequence from left to right. No Combinations required. And No Duplicates)
calculating cumulative
cumulative stats
stats for
for quarters




3 Words List: (Same condition as 2 Words List. And No Duplicates)
calculating cumulative stats
cumulative stats for
stats for quarters

-----------------------------------------------------------------------------------------------------------------------------------------------------------


Thanks in advance.
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Try this for strings in column "A" starting "A2", with result in subsequent columns for each string, starting "B2".
Code:
[COLOR="Navy"]Sub[/COLOR] MG19Dec29
[COLOR="Navy"]Dim[/COLOR] Sp [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Tim [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
col = 1

[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
col = col + 1: c = 2
Sp = Split(Dn.Value, " ")
Cells(c, col).Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)

c = UBound(Sp) + 5
[COLOR="Navy"]For[/COLOR] Tim = 1 To 2
[COLOR="Navy"]For[/COLOR] n = 0 To UBound(Sp) - Tim
    c = c + 1
    [COLOR="Navy"]For[/COLOR] Ac = n To n + Tim
        Cells(c, col) = Cells(c, col) & " " & Sp(Ac)
    [COLOR="Navy"]Next[/COLOR] Ac
[COLOR="Navy"]Next[/COLOR] n
c = c + 3
[COLOR="Navy"]Next[/COLOR] Tim
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Try this for results in column "B".
Code:
[COLOR="Navy"]Sub[/COLOR] MG19Dec34
[COLOR="Navy"]Dim[/COLOR] Sp [COLOR="Navy"]As[/COLOR] Variant, n [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Ac [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] c [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long,[/COLOR] Tim [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Dim[/COLOR] Rng [COLOR="Navy"]As[/COLOR] Range, Dn [COLOR="Navy"]As[/COLOR] Range, col [COLOR="Navy"]As[/COLOR] [COLOR="Navy"]Long[/COLOR]
[COLOR="Navy"]Set[/COLOR] Rng = Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
Range("B:B").ClearContents
c = 2

[COLOR="Navy"]For[/COLOR] [COLOR="Navy"]Each[/COLOR] Dn [COLOR="Navy"]In[/COLOR] Rng
Sp = Split(Dn.Value, " ")
Cells(c, "B").Resize(UBound(Sp) + 1).Value = Application.Transpose(Sp)
    c = c + UBound(Sp) + 5
    [COLOR="Navy"]For[/COLOR] Tim = 1 To 2
        [COLOR="Navy"]For[/COLOR] n = 0 To UBound(Sp) - Tim
            c = c + 1
            [COLOR="Navy"]For[/COLOR] Ac = n To n + Tim
                Cells(c, "B") = Cells(c, "B") & " " & Sp(Ac)
            [COLOR="Navy"]Next[/COLOR] Ac
        [COLOR="Navy"]Next[/COLOR] n
        c = c + 3
    [COLOR="Navy"]Next[/COLOR] Tim
[COLOR="Navy"]Next[/COLOR] Dn
[COLOR="Navy"]End[/COLOR] [COLOR="Navy"]Sub[/COLOR]
Regards Mick
 
Upvote 0
Hi,

Formula solution options:


Book1
ABC
1calculating cumulative stats for quarters
2calculatingcalculating cumulativecalculating cumulative stats
3cumulativecumulative statscumulative stats for
4statsstats forstats for quarters
5forfor quarters
6quarters
7
8
91 word2 words3 words
Sheet410
Cell Formulas
RangeFormula
A2=TRIM(MID(SUBSTITUTE(A$1," ",REPT(" ",LEN(A$1))),(ROWS(A$2:A2)-1)*LEN(A$1)+1,LEN(A$1)))
B2=IF(LEN(A$1)-LEN(SUBSTITUTE(A$1," ",""))A$2:A2),"",TRIM(MID(SUBSTITUTE(A$1," ",REPT(" ",LEN(A$1))),(ROWS(A$2:A2)-1)*LEN(A$1)+1,LEN(A$1)*2)))
C2=IF(LEN(A$1)-LEN(SUBSTITUTE(A$1," ",""))<=ROWS(A$2:A2),"",TRIM(MID(SUBSTITUTE(A$1," ",REPT(" ",LEN(A$1))),(ROWS(A$2:A2)-1)*LEN(A$1)+1,LEN(A$1)*3)))


Formulas copied down.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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