+ Reply to Thread
Results 1 to 6 of 6

[SOLVED] renumber numbers?

  1. #1
    Registered User
    Join Date
    10-14-2010
    Location
    Midland., MI
    MS-Off Ver
    2019
    Posts
    10

    Lightbulb [SOLVED] renumber numbers?

    say column A is a list of numbers:

    [A]
    1
    1
    1
    1
    1
    2
    2
    2
    3
    3
    3

    say i would like to re-number the numbers to the following 1=29, 2=40, 3=5

    [A]
    29
    29
    29
    29
    29
    40
    40
    40
    5
    5
    5

    is there any way to accomplish this?
    thanks.
    Last edited by nickdclements; 10-18-2010 at 08:10 AM. Reason: solved

  2. #2
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: renumber numbers?

    MASS REPLACE
    I have a macro for searching for a series of strings and replacing them with a new set of values:
    Mass Replace

    To use the macro as is:
    1. create a new sheet called Categories
    2. put the values to find in column A
    3. put the replacement values in column B

      The order of the values in columns A and B are important, make sure you're going in the correct order to not create problems as you work down the list

    4. name your sheet to search Data
    5. run the macro

    You should probably change the parameter xlPart to xlWhole in the macro, too.
    _________________
    Microsoft MVP 2010 - Excel
    Visit: Jerry Beaucaire's Excel Files & Macros

    If you've been given good help, use the icon below to give reputation feedback, it is appreciated.
    Always put your code between code tags. [CODE] your code here [/CODE]

    ?None of us is as good as all of us? - Ray Kroc
    ?Actually, I *am* a rocket scientist.? - JB (little ones count!)

  3. #3
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    Microsoft 365
    Posts
    14,702

    Re: renumber numbers?

    If you create a table somewhere on the worksheet with the original numbers listed in one column, e.g. in D2 down, 1,2,3.....and then in E2 down the corresponding numbers you want to change them to, 29, 40, 5...

    Then in B1 copied down

    =VLOOKUP(A1,D$2:E$100,2,0)

    That will give you the revised numbers in column B. If you actually want those numbers to replace column A just selct column B, copy, then Edit > Paste Special > Values - now delete column A
    Audere est facere

  4. #4
    Registered User
    Join Date
    10-14-2010
    Location
    Midland., MI
    MS-Off Ver
    2019
    Posts
    10

    Re: renumber numbers?

    @JBeaucaire Thanks! That worked like a charm.

  5. #5
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: renumber numbers?

    If that takes care of your need, please click EDIT in your original post, click GO ADVANCED and set the PREFIX box to SOLVED.

  6. #6
    Forum Expert JBeaucaire's Avatar
    Join Date
    03-21-2004
    Location
    Bakersfield, CA
    MS-Off Ver
    2010, 2016, Office 365
    Posts
    33,492

    Re: [SOLVED] renumber numbers?

    Nick,

    As per your email regarding odd results using the MASS REPLACE macro to search/replaces a series of text strings, you cited:
    FIND: CHANGE:
    bill...... mark
    mark.... sam

    If you run "Mass Replace" on this set of data, 'bill' will change to sam, not mark -- as "Mass Replace" will find 'bill' change it to 'mark,' and than see 'mark' and change it to 'sam.'
    You are correct. When dealing with strings it's up to the user to construct the table so that this doesn't happen. In other words you're searching in the wrong order. The correct table would look like:

    FIND: CHANGE:
    mark.... sam
    bill...... mark


    This would find "mark" and turn it into "sam". Then you're free to find "bill" and turn it into "mark".

    Never search in a subsequent search for a string you've already used as the REPLACE in an earlier iteration.

    Also:
    Quote Originally Posted by JBeaucaire View Post
    You should probably change the parameter xlPart to xlWhole in the macro, too.
    In your scenarios this adjustment would resolve what you're showing as well.
    Last edited by JBeaucaire; 11-10-2010 at 08:38 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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