+ Reply to Thread
Results 1 to 10 of 10

Count spaces in a cell starting from the right and return charters after spaces in text.

  1. #1
    Registered User
    Join Date
    03-14-2017
    Location
    Louisville, KY
    MS-Off Ver
    Office 365 2016
    Posts
    8

    Count spaces in a cell starting from the right and return charters after spaces in text.

    I am attempting to make a PDF report converter in excel. When I copy and paste regular reports the data shows up like this in each cell. Rather than using the “Text to Columns” feature, I want to use formulas on sheet two to cut down on the repetitive manual tasks.

    When pasted the data looks like this:
    Store 0056 Green Red Blue 9 10 4 59 34 20 12/31/2018

    I need to extract the numbers 9, 10, 4, 59, 34, and 20 as shown in the example above. The colors can be variable so using a character count formula such as Left() won’t be accurate. I believe it would work if I could count the spaces starting from the right side of the cell and return the string of text until it reach another space. For example if I could tell excel to start from the RIGHT() and count 5 spaces to the left, it would return the number 10.

    Any idea how this might work?

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,879

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    Have you thought of using Power Query?
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Registered User
    Join Date
    03-14-2017
    Location
    Louisville, KY
    MS-Off Ver
    Office 365 2016
    Posts
    8

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    I'm not very familiar with the abilities or limitations of power query. Not sure how that would work.

  4. #4
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,879

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    Can you provide a larger dataset and I can attempt to show you.

  5. #5
    Registered User
    Join Date
    03-14-2017
    Location
    Louisville, KY
    MS-Off Ver
    Office 365 2016
    Posts
    8

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    Store 6125 Red Green Blue 6 6 4 4 0 0
    Store 0021 Green Blue Orange 5 5 5 5 1 1
    Store 0023 Red Yellow 91 67 38 26 52 36
    Store 0030 Blue Green 9 7 11 6 1 1
    Store 0033 Yellow Red Brown 11 8 10 10 8 5
    Store 0034 Black White 25 23 16 12 13 11
    Store 0035 Green Blue Orange 57 50 30 22 30 48
    Department 0041 Red Green Blue 50 35 19 15 17 9
    Department 0044 Green Blue Orange 15 12 7 8 4 3
    Department 0045 Red Yellow 37 28 20 18 9 11
    Department 0046 Blue Green 52 40 36 24 29 36
    Department 0054 Yellow Red Brown 20 13 15 11 0 0
    Department 0150 Black White 7 7 2 2 0 0
    Department 0263 Green Blue Orange 21 13 18 14 0 0
    Department 0303 Red Yellow 36 29 19 14 16 24
    Attached Files Attached Files

  6. #6
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,879

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    Have a look at the attached and let me know - if it's of any use, I will talk you through it.

    M Code:
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by AliGW; 12-31-2018 at 12:28 PM.

  7. #7
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    Not pretty but in B2 copied down

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Then copy column B and paste back as values

    Finally use TextToColumns and specify the space character as the delimiter.
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  8. #8
    Registered User
    Join Date
    03-14-2017
    Location
    Louisville, KY
    MS-Off Ver
    Office 365 2016
    Posts
    8

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    So neither of the solutions really worked for my needs, because some of the colors names have numbers in them also. I changed the data for posting. The solution I found that worked I found from another posting online. Here is the formula:

    In this example cell C483 was the referenced cell:

    IFERROR(TRIM(MID(SUBSTITUTE(C483," ","ᴓ",LEN(C483)-LEN(SUBSTITUTE(C483," ",""))-11),SEARCH("ᴓ",SUBSTITUTE(C483," ","ᴓ",LEN(C483)-LEN(SUBSTITUTE(C483," ",""))-11))+1,LEN(SUBSTITUTE(C483," ","ᴓ",LEN(C483)-LEN(SUBSTITUTE(C483," ",""))-11)))),"")

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,879

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    OK - thanks for letting us know. Please always provide properly representative sample data in future to ensure that solutions offered will fit your requirements.

  10. #10
    Forum Guru Bo_Ry's Avatar
    Join Date
    09-10-2018
    Location
    Thailand
    MS-Off Ver
    MS 365
    Posts
    7,211

    Re: Count spaces in a cell starting from the right and return charters after spaces in tex

    Please try at
    B1 copy down
    =TRIM(RIGHT(SUBSTITUTE(TRIM(A1)," ",REPT(" ",50)),300))

    or C1 copy to the right and down
    =TRIM(MID(RIGHT(SUBSTITUTE(TRIM($A1)," ",REPT(" ",50)),300),COLUMNS($C1:C1)*50-49,50))

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Return value between the first two spaces in a cell
    By Dendrinos2 in forum Excel General
    Replies: 2
    Last Post: 07-24-2014, 12:40 PM
  2. [SOLVED] Formula to count the number of spaces before text/number is written in a cell.
    By kmis in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 06-12-2013, 05:05 PM
  3. [SOLVED] How to count the number of 'spaces' in a cell.
    By Leizure in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 09-04-2012, 04:08 PM
  4. Count spaces between last two words in a text string
    By mkvassh in forum Excel General
    Replies: 4
    Last Post: 10-26-2011, 03:33 AM
  5. How to Count number of spaces in between two data in a cell
    By pradeepdeepu_001 in forum Excel General
    Replies: 3
    Last Post: 02-02-2010, 08:35 AM
  6. Function to count text spaces in a cell.
    By dcgrove in forum Excel General
    Replies: 10
    Last Post: 11-10-2009, 05:46 PM
  7. Count spaces in front of text
    By poppy in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 07-07-2006, 02:24 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1