+ Reply to Thread
Results 1 to 3 of 3

Count strings and add columns

  1. #1
    Registered User
    Join Date
    03-24-2011
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Count strings and add columns

    I've been using VBA to do some basic repetitive tasks and use the recorder to get me started but this is beyond me. I have data in 14 to 25 columns of cells that contain 2 to 90 separate numerical strings. The strings within the cells are all delimited by spaces so my plan is to just use something like the text to columns function to split but I need to add columns for the data to flow into.
    What I think I need is a VBA equivalent of X =LEN(AH6)-LEN(SUBSTITUTE(AH6," ","")) that counts the number of spaces and therefore strings I have in the cell, that number can then be entered into a for, next statement to loop through the insertcolumns function.
    My questions are then
    1. how do I do the above function in VBA and
    2. How do I put the result into the For count = 1 to X statement
    I’d like help on this bit first then I’ll figure out why the rest of the plan wont work.
    Thanks

  2. #2
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Count strings and add columns

    Assuming columns 14 to 25 constitute 1 table:

    Please Login or Register  to view this content.



  3. #3
    Registered User
    Join Date
    03-24-2011
    Location
    Perth, Australia
    MS-Off Ver
    Excel 2007
    Posts
    6

    Re: Count strings and add columns

    Sorry, I don't think that works, d/t my explanation, it isn't a table of 11 columns its a sheet with at least 14 but up to 25 columns that need working on.
    I've attached a sample of the data. In this sheet the majority of the data concerned is in U5:AG10 but in a real sheet the rows are variable, the one I've clipped this from is really U5:AG561.
    You can also see that AA3:AB4 also have data that needs splitting and there is one more column in the original sheet as well, its location appears to occur at the end of the data set in 'all' cases. Essentially any cell that has multiple strings of data needs to be split into multiple columns.
    Thanks,
    Attached Files Attached Files

+ 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