+ Reply to Thread
Results 1 to 17 of 17

Macro to replace numbers with specific text value

  1. #1
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Red face Macro to replace numbers with specific text value

    Hi, All!

    Everyday I get an excel sheet with 400k records that has repetative numbers from 1 to 300 in 1st column. I have list (300) of text values, and the number in 1st column needs to be replaced by its specific text value.

    For ex: if number=1 then replace it with "Apple", If number=2 then replace it with "boy".............If number=300 then replace it with "ZebraZebraZebra...."

    Would someone help me to write a macro to do this.

    Appreciate your help .

    Thank you!

    Shayk

  2. #2
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Hello Shayk,

    Welcome to the Forum!

    I could be possible without VBA Code, but it would be much easier if you could attach a sample workbook, for us to see where this list (300) of text values is.

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.


    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  3. #3
    Forum Contributor kalbasiatka's Avatar
    Join Date
    02-27-2016
    Location
    Brest, Belarus
    MS-Off Ver
    2021
    Posts
    224

    Re: Macro to replace numbers with specific text value

    Please Login or Register  to view this content.
    To do it for me and help me it is 2 different things!
    Sorry for my english, blame Google translator

  4. #4
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    Spreadsheet attached.
    Attached Files Attached Files

  5. #5
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Hello Shayk,

    There are no values Assigned to the Names on the "Value Assigned" Sheet.

    Could you please do that for us?

    Thank you.

  6. #6
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    The 1st column of sheet1 has ID's that needs to be replaced. The "value assigned" sheet has number in column1 and the text value for that number in column 2.

    If the value in column1, sheet1 = 1 then replace it with the value which is in column2, sheet2.

    In the spreadsheet if you go to A9, sheet1 = 176 then it should be replaced by A177,Value Assigned which is text value "xavier"

    Hope this helps. Please let me know.

    Thank you!.

    Shayk.

  7. #7
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    Hello Kalbasiatka,

    Your macro worked but it is replacing all the other columns which has numbers in it. I want the values replaced only in 1 column or 5 column. Would you please correct it so that it does not replace values in other columns.

    Thanks,
    Shayk

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Hello Shayk,

    Thank you for the Clarification.

    If you Replace the Number in Column A in Sheet1 with the name on Sheet "Valued Assigned" you will lose the ability to verify if the Data presented is correct. Would it be O.K. with you if we return the desired results in, say Column C of Sheet1 instead of Column A?
    Last edited by Winon; 11-02-2016 at 04:38 PM. Reason: Spelling

  9. #9
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    Yes, that's perfectly fine.

    Thank you!.

    Shayk

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Hello Shayk,

    Thank you for the feedback.

    In C2 of Sheet1 enter the formula below, and drag it down as far as required.

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Enjoy!

    Kind Regards.

  11. #11
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    Hi Winon,

    As I said I have 400k records and sometimes more than that. Dragging will be very difficult. Is there a possibility to create a macro out of it.

    Appreciate your help.

    Thanks,
    Shayk

  12. #12
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Here you go Shayk,

    Place the Code below in a Standard Module. You may link it to a Button of your choice!


    Please Login or Register  to view this content.
    Regards,

    W.

  13. #13
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    Awesome!!!!!!!!!! You made my day . Thank you very such. Your help is appreciated .

    Kind Regards,
    Shayk

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

    Re: Macro to replace numbers with specific text value

    Try
    Please Login or Register  to view this content.

  15. #15
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Hello Shayk,

    Thank you for the Rep, Much appreciate!

    The Code Below is even better:

    Please Login or Register  to view this content.
    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.


    Thanks.

  16. #16
    Registered User
    Join Date
    11-02-2016
    Location
    Phoenix, AZ
    MS-Off Ver
    10
    Posts
    13

    Re: Macro to replace numbers with specific text value

    Hi Winon,

    I appreciate your help. I need one more help to execute the code. When I'm executing the macro for 50k records in excel it runs fine without issues but when i run the same for 1048587 records it gives 400 error.

    Do you know what is causing this?

    Appreciate your help in this matter.

    Thank

  17. #17
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Macro to replace numbers with specific text value

    Hello Shayk,

    when i run the same for 1048587 records it gives 400 error.
    That happens because a Column has only 1048576 Rows. If your actual records start on, say Row 5 of a Column, the maximum number of rows you could work with records would become 1048576 - 5 Rows.
    Leaving you with only 1048571 Rows of Records which is still more than the maximum any column could handle.

    With the above in mind it tells me that your actual number of Records Flow over into other adjacent columns, whilst our solution looks at only one Column.

    To best assist us in finding a solution for you with this scenario, it would be best if you could attach a sample workbook, showing us which Columns are at play here. You don't need to fill the Columns right down to the bottom of any Column, 50 to 100 Rows for each Column will suffice. It would even be better if you could leave a "Blank" Column between each two Columns which might be containing you Records.

    Make sure there is just enough data to demonstrate your need. Include a BEFORE sheet and an AFTER sheet in the workbook if needed to show the process you're trying to complete or automate. Make sure your desired results are shown, mock them up manually if necessary.

    Remember to desensitize the data.

    Click on GO ADVANCED and then scroll down to Manage Attachments to open the upload window.

    Regards.

+ 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. Replies: 1
    Last Post: 07-20-2016, 10:12 AM
  2. Replace sepcific text with specific numbers
    By etaver87 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 05-10-2016, 11:37 AM
  3. [SOLVED] Macro for find/replace specific text within a column
    By majkkali in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-18-2015, 10:59 AM
  4. [SOLVED] Search through columns and find specific text and replace that text with header column
    By adamzee in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-09-2014, 11:59 PM
  5. Macro to find header information and replace with specific text
    By Nancy Taylor in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-15-2013, 04:47 PM
  6. Macro required for changing numbers to specific text
    By amolryeolekar in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-18-2013, 01:26 PM
  7. macro to replace specific data with column header text
    By wkilc in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-12-2010, 11:52 AM

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