+ Reply to Thread
Results 1 to 7 of 7

Text to Columns based on column name

  1. #1
    Registered User
    Join Date
    10-23-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    5

    Text to Columns based on column name

    I am repeatedly performing a task to format a couple of columns to remove leading zeros.

    Currently I am running 'Text to Columns' on each individual field and selecting Delimited, Tab and General, which will lose the leading zeros.

    I would like to automate this however using VBA, however I am struggling with the code.

    I only want to perform this output on two columns;

    SORTSEQ
    BAGNO

    I would really appreciate some help.

  2. #2
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Text to Columns based on column name

    What type of data is in those 2 columns, I presume they are numbers with leading 0's?

    From your description it sounds like you have numbers stored as text and are using text to columns to convert them to numeric values, is that correct?

    Can you post a sample with your raw data (before txt to columns) and after (what it looks like after you do it manually)?

    There are at least 3 ways to do this manually, which means there is at least 3 ways to do it via VBA I can think of, which way we use will depend on how your data is structured.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Text to Columns based on column name

    What code do you have and what problems are you having?

    It should be straightforward to find the 2 columns you want to work on and incorporate that into the code.
    If posting code please use code tags, see here.

  4. #4
    Registered User
    Join Date
    10-23-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    5

    Re: Text to Columns based on column name

    Sorry for the late reply - I have been off for the Christmas holidays.

    Yes that's correct, the numbers are stored as text, however I want to convert to number which will in turn remove the leading zeros.

    Example data before text to columns;

    000001
    000002
    000003
    000004
    000005

    Example data after text to columns;

    1
    2
    3
    4
    5

    Some code to automate this process for the columns named 'SORTSEQ' and 'BAGNO' would be a great help!

    Thanks again.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,591

    Re: Text to Columns based on column name

    Try
    Please Login or Register  to view this content.

  6. #6
    Registered User
    Join Date
    10-23-2017
    Location
    England
    MS-Off Ver
    2016
    Posts
    5

    Re: Text to Columns based on column name

    Perfect, thank you for your quick response

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,591

    Re: Text to Columns based on column name

    You are welcome.

    If that takes care of your original question, please select Thread Tools from the menu link above and 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. Show a Text on a Column based on the values in Two separate columns
    By Harshadewa in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-31-2017, 09:59 AM
  2. [SOLVED] Create text file based off of common text in column A with data in columns B-F
    By BG1983 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-14-2016, 12:47 PM
  3. [SOLVED] Can you calculate columns based on specific text in a different column?
    By CenterShock in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2014, 03:52 PM
  4. mode of text columns based on another text column
    By HEIDYS7 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-05-2013, 04:38 PM
  5. Replies: 11
    Last Post: 01-02-2013, 10:14 AM
  6. [SOLVED] Enter text in column a based on data in several other columns for groups of rows
    By mrswain in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-27-2012, 03:29 PM
  7. [SOLVED] Conditional Formatting Columns Based on Text from Adjacent Column
    By mejiamang in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 10-18-2012, 10:41 PM

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