+ Reply to Thread
Results 1 to 7 of 7

Wildcards

  1. #1
    Registered User
    Join Date
    07-19-2007
    Posts
    10

    Wildcards

    Hi,

    Does Xl or VB have a wildcard for numerical data, and is there a different wildcard for all text data.

    I know of * and ? wildcards but these are brutal in their application as they make no distinction between alpha and numerical charcters.

    Any help is much appreciated.

    Best regards
    Richard

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Hello Richard,

    not sure about VB but there are only those wildcards for use in worksheet functions. Do you have a specific problem?

  3. #3
    Registered User
    Join Date
    07-19-2007
    Posts
    10
    Hi Daddylonglegs,

    My specific problem is:

    If I have a single column consisting of say 20,000 lines, each cell contains a variable length string, which begins with variable length text (including spaces) and is followed by variable legth numbers which are space delimited.

    A small example of this data is shown below:
    Turnover 100,000 50,000
    Costs of sales (30,000) (15,000)
    Gross profits 70,000 35,000

    Question: How to normalise this data into 3 columns. The first column containing the description, the second column the number, the third column the next number along in the string.

    If I run "text text to columns" and used delimited by space, then xl puts a column in after the word "costs" and "of" and "sales". So I end up with unusable data, which is not all aligned in the right columns.
    Clearly I do not want to use "format as fixed width" as this would be a manual job and take ages.

    Any ideas?

    I know there is a * wildcard in XL and also ? is used, but in this example these two wildcards do not help me.
    Is there a wildcard in XL for numerical data (like #), and text data.


  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    You might be able to use this approach, assuming your data is in A1 down then use these 3 formulas in B1, C1 and D1 and copy down the columns.

    =TRIM(LEFT(A1,MIN(FIND({0,1,2,3,4,5,6,7,8,9,"("},A1&"0123456789("))-1))

    =LEFT(TRIM(SUBSTITUTE(A1,B1,"")),FIND(" ",TRIM(SUBSTITUTE(A1,B1,"")))-1)

    =TRIM(SUBSTITUTE(SUBSTITUTE(A1,B1,""),C1,""))

  5. #5
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675
    Note: the above approach will make the numerical values "text formatted" which might cause you problems if you want to use these for calculations. to make columns C and D numeric change the last 2 formulas to

    =LEFT(TRIM(SUBSTITUTE(A1,B1,"")),FIND(" ",TRIM(SUBSTITUTE(A1,B1,"")))-1)+0

    and

    =TRIM(SUBSTITUTE(SUBSTITUTE(A1,B1,""),TEXT(C1,"#,###;(#,###);0"),""))+0

    and then you can format these columns any way you want (including using brackets for negative numbers)

  6. #6
    Registered User
    Join Date
    07-19-2007
    Posts
    10
    Nice one Daddy

    Looks like this would work, although it doesn't look a particularly elegant solution.

    Are there any other ways to sort this?

    Thanks for the help.
    Best regards
    Richard

  7. #7
    Registered User
    Join Date
    07-19-2007
    Posts
    10

    Thumbs up

    Hi Daddylonglegs.

    I have had another potential solution by solnajeff, but on comparison yours seems most robust.

    Thank your valuable advice.

    Best regards
    Richard

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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