+ Reply to Thread
Results 1 to 6 of 6

Delimiting Data with Fixed Width w/o Breaking Words

  1. #1
    Registered User
    Join Date
    05-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Delimiting Data with Fixed Width w/o Breaking Words

    Hello,

    I am trying to break up information in cells to fit a 30 character fixed length. The information in the cells is alpha numerical. I need the cells to be split by a space (" "), or in between words.

    So for example if the cell has 150 characters with spaces throughout, it would need to be broken up into 5 different cells at a "space" that makes each cell receive as close to 30 characters as possible. Note I will be mapping this to a server and only 5 cells of no more than 30 characters can be used.

    I was trying to write a vba code that determined the locations of the spaces and then split them based on their position, that works with descriptions that are 60 and fewer characters, but not larger as is doesn't always align to 30 characters after the split. I was going to write in a len() verification check to mitigate.

    For my particular project, I have data in Column "B" starting at row 2. I need this information broken down to columns B-F depending on # of characters in the original cell. Also need the code to be smart enough to truncate any extra information if it exceed the 30 character limit in the last column.

    I thought this was going to be fairly easy (have little to basic coding background where in vba I know what it can do but not always how to write the code, thanks google and forums). I would paste what I have but I think I am far off of the end result as right now my code only finds the first space in the data.

    If anyone could help, that would be greatly appreciated.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Delimiting Data with Fixed Width w/o Breaking Words

    This VBA code will do it, has been tested. It will operate on the active sheet.

    if the cell has 150 characters with spaces throughout, it would need to be broken up into 5 different cells
    Note that the arithmetic of this dictates that there will be at least 5 cells.
    I need this information broken down to columns B-F
    B is your source data so you have to start in C. Results may well go beyond G. This code will use as many columns as needed.

    Please Login or Register  to view this content.
    Jeff
    | | |·| |·| |·| |·| | |:| | |·| |·|
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Registered User
    Join Date
    05-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Delimiting Data with Fixed Width w/o Breaking Words

    This worked!

    Only note is that I wanted it to repaste in column B and move over from there. No big deal, just added another column before running the code. Mentioning in case someone else has a similar project so as to be careful as it will over write or add onto the back end of the "5th" column.

    Thank you for the timely response! I really appreciate it!

  4. #4
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Delimiting Data with Fixed Width w/o Breaking Words

    You mean you want to wipe out the original text in column B? This change ought to do it.
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    05-23-2022
    Location
    Houston, Texas
    MS-Off Ver
    Microsoft 365
    Posts
    3

    Re: Delimiting Data with Fixed Width w/o Breaking Words

    That worked perfectly! Thanks for the updated code!

  6. #6
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS365 Family 64-bit
    Posts
    24,696

    Re: Delimiting Data with Fixed Width w/o Breaking Words

    You're welcome!

    If your question has been answered please mark your thread as "Solved" so that members will know by looking at the thread title that your problem is solved. Go to the menu immediately above your first post to the thread and click on Thread Tools. From the dropdown menu select "Mark this thread as solved..."

+ 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. Fixed Width Delimiting - with specific values
    By Phlegon_of_Tralles in forum Excel General
    Replies: 5
    Last Post: 10-11-2017, 10:37 AM
  2. [SOLVED] Fixed Width Data Importing
    By PaulPerger in forum Excel General
    Replies: 5
    Last Post: 09-30-2014, 01:23 PM
  3. Importing Fixed Width Text Data Into Excel
    By jgsuf in forum Excel General
    Replies: 3
    Last Post: 08-21-2014, 01:48 PM
  4. repeated import of similar fixed width data files
    By riwiseuse in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2013, 10:50 AM
  5. Fixed Width Text to Excel with fixed break lines.
    By jameel30 in forum Word Formatting & General
    Replies: 1
    Last Post: 08-10-2012, 08:57 PM
  6. Problem with importing multiple data files with fixed width format
    By sport_logo in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-21-2010, 07:34 AM
  7. Help: How do I create a column of fixed width data?
    By limshady411 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-14-2005, 07:10 PM

Tags for this Thread

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