+ Reply to Thread
Results 1 to 5 of 5

Code to find a text column, truncate it, change it to numbers, total and weight it

  1. #1
    Registered User
    Join Date
    06-22-2012
    Location
    San Jose, California
    MS-Off Ver
    Excel 2010
    Posts
    15

    Code to find a text column, truncate it, change it to numbers, total and weight it

    Hey,
    Thank you in advance for the help. It means a lot, and will save me a lot of time and headaches.

    I am trying to write a code which will take a column of text labelled "Market Cap", cut the text down to 5 characters, convert this to numerals, and then sum it up at the bottom of the column. Then in another column, labelled "Weights" It will take each of the values in the "Market Cap" column and divide it by the total and convert it to a percentage. I need help writing code which will find "Market Cap" and do this.

    Ex: Market Cap Market Cap Weights
    12.35B Change To 12.35 17.82%
    43.54B -------> 43.53 62.81%
    13.43B 13.43 19.20%
    Sum 69.31

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Code to find a text column, truncate it, change it to numbers, total and weight it

    You get better help if you post an Excel-example of your workbook, without confidential information.

    Make sure the workbook demonstrates your desired results if possible, or just highlight the cells you're trying to fix.

    Use BEFORE/AFTER sheets if that helps make it clearer.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Registered User
    Join Date
    06-22-2012
    Location
    San Jose, California
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Code to find a text column, truncate it, change it to numbers, total and weight it

    In the "Before" column, the numbers entered are formatted as text. They need to be reformatted as numbers, and the "B" has to be removed

    Before
    Market Cap
    14.23B
    98.87B
    12.34B
    After
    Market Cap Weightages
    14.23 11.34%
    98.87 78.82%
    12.34 9.84%
    Sum: 125.44

  4. #4
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Code to find a text column, truncate it, change it to numbers, total and weight it

    For the future, you helped better if you add an Excel example, so the forum members don't have to built your question.

    CTRL + H
    find B
    replace empty (don't put anything in it)
    replace all

    See the example.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    06-22-2012
    Location
    San Jose, California
    MS-Off Ver
    Excel 2010
    Posts
    15

    Re: Code to find a text column, truncate it, change it to numbers, total and weight it

    Thanks oeldere,
    I see what you mean, and how by attaching a file it can clear a lot of the confusion. Take a look at the attached file

    I was hoping for a VB code that could do this since the position of the "Market Cap" Column, as well as the number of items in the column are variable.
    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