+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 15 of 18

FIND & REPLACE rows of text in an Excel worksheet

  1. #1
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    FIND & REPLACE rows of text in an Excel worksheet

    I have spreadsheets with rows containing certain text which I have to replace with revised text as shown below.

    There are only 3 strings of text that need replacing in each worksheet however they could appear in any rows.

    IMPORTANT: Replacement text in brackets () must be bold with a red font.


    •“Electric in Pasture (CLAIM 100%)” TO “Electric in Pasture (CLAIM 100%)”

    •“Electric in Yard (represents 66.6%)” TO “Electric in Yard (figures represent 66.6%)”

    •“Natural Gas (represents 50%)” TO “Natural Gas (figures represent 50%)”


    HERE ARE SOME ROWS OF THE SPREADSHEET CONTAINING TEXT WHICH MUST BE REPLACED BUT MAY OCCUR IN ANY ROW:


    A B C D E F

    XXXXXXXXXX 2017

    Transactions by Account Report 01/01/2017 to 31/12/2017

    Sorted by: Date

    Date Comment Source # Debits Credits Balance

    5710 Electric in Pasture (CLAIM 100%) REPLACE WITH: “Electric in Pasture (CLAIM 100%)” 0.00 Dr
    18/01/2017 electric SW 30-21-5-4 pasture (CLAIM 100%) ATCO Electric 36.22 0.00 36.22 Dr
    15/02/2017 electric SW 30-21-5-4 pasture (CLAIM 100%) ATCO Electric 30.73 0.00 66.95 Dr
    17/03/2017 electric SW 30-21-5-4 pasture (CLAIM 100%) ATCO Electric 32.92 0.00 99.87 Dr
    5720 Electric in Yard (represents 66.6%) REPLACE WITH: “Electric in Yard (figures represent 66.6%)” 0.00 Dr
    20/01/2017 electric SW 28-21-5-4 including house (figures represent 66.6%) Direct Energy 101.10 0.00 101.10 Dr
    17/02/2017 electric SW 28-21-5-4 including house (figures represent 66.6%) Direct Energy 123.74 0.00 224.84 Dr
    21/03/2017 electric SW 28-21-5-4 including house (figures represent 66.6%) Direct Energy 110.91 0.00 335.75 Dr

    5860 Natural Gas (represents 50%) REPLACE WITH: “Natural Gas (figures represent 50%)” 0.00 Dr
    10/01/2017 gas utilities including house (figures represent 50%) Dry Country Gas 152.27 0.00 152.27 Dr
    08/02/2017 gas utilities including house (figures represent 50%) Dry Country Gas 124.55 0.00 276.82 Dr
    07/03/2017 gas utilities including house (figures represent 50%) Dry Country Gas 57.28 0.00 334.10 Dr

    Thanks in advance for any help you can give,

    Jerry

  2. #2
    Forum Moderator Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    Excel 2010 on Linux
    Posts
    7,662

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Attach a sample workbook (not a picture or pasted copy). 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.

  3. #3
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Thank you Pepe Le Mokko! The files are uploaded.
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    So sorry Pepe, my files still had the .xls extension instead of the .slsx extension. I will replace right now!

  5. #5
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Hi again Pepe...new files are now uploaded.
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    703

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Try

    Please Login or Register  to view this content.
    Last edited by mohan.r1980; 01-12-2019 at 05:38 AM. Reason: change the code
    Regards,
    MohanS


    "Perfection is not attainable, but if we chase perfection we can catch excellence." - Vince Lombardi

    You can simply say thanks by clicking "*Add Reputation" icon

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    14,667

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Quote Originally Posted by afterdinnerspeaker View Post
    IMPORTANT: Replacement text in brackets () must be bold with a red font.


    •“Electric in Pasture (CLAIM 100%)” TO “Electric in Pasture (CLAIM 100%)”

    •“Electric in Yard (represents 66.6%)” TO “Electric in Yard (figures represent 66.6%)”

    •“Natural Gas (represents 50%)” TO “Natural Gas (figures represent 50%)”
    Try
    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Thank you MohanS, however your code doesn't initiate.

    The code sent by jindon seems to do exactly what I need.

    However, I do appreciate you working on it for me, Jerry

  9. #9
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Thank you so much jindon!

    The code you provided works instantly, like magic.

    I sincerely appreciate your efforts and for solving this for me.

    Regards,

    Jerry

  10. #10
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    14,667

    Re: FIND & REPLACE rows of text in an Excel worksheet

    You are welcome and thanks for the feedback.

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

  11. #11
    Valued Forum Contributor mohan.r1980's Avatar
    Join Date
    09-18-2010
    Location
    Mumbai, India
    MS-Off Ver
    Excel 2010 (windows7)
    Posts
    703

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Thank you MohanS, however your code doesn't initiate.

    The code sent by jindon seems to do exactly what I need.

    However, I do appreciate you working on it for me, Jerry
    No Problem jerry,
    Jindon Sir has unique style of scripting.
    He is "GURU" of this Forum and me also.
    he always has right solution.

    @Jindon Sir,
    Nice Scripting sir
    Last edited by mohan.r1980; 01-13-2019 at 10:07 AM.

  12. #12
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Quote Originally Posted by jindon View Post
    Try
    Please Login or Register  to view this content.
    Hi again jindon!

    Sorry to bother you again...especially since it's been almost two months ago that you solved my "Find & Replace" problem.

    Your code works like "magic" and I admire your talent.

    In an attempt to learn, I've been trying to "dissect" your code to find out how I could either change or add another "FIND & REPLACE" argument if required.

    From time to time, I make slight changes to headings and wonder if you could explain the process so I could either:

    1. change the "original" & "replacement" text in your code OR

    2. add another row with different text to be replaced

    Your code is way above my understanding and would really appreciate if you could be so kind as to add some comments so I could better understand what's happening.

    Thanks so much in advance,

    Jerry

  13. #13
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013
    Posts
    14,667

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Since I can not even guess how you want to change the code, it will help if you tell me where do you not understand.

    Even better uploading sample workbook, so that you will see the change.

  14. #14
    Registered User
    Join Date
    01-12-2019
    Location
    Calgary, AB
    MS-Off Ver
    2010
    Posts
    24

    Re: FIND & REPLACE rows of text in an Excel worksheet

    Quote Originally Posted by jindon View Post
    Since I can not even guess how you want to change the code, it will help if you tell me where do you not understand.

    Even better uploading sample workbook, so that you will see the change.
    Thanks again,

    I've attached the original two sample files you used to write the code (Before Spreadsheet & After Spreadsheet).

    Right now, I won't concentrate on making any further changes to the spreadsheet.

    Instead, maybe you could just add a few comment lines to the macro you wrote which might help me understand the process you used to make the changes to those three rows.

    If I could follow the commands you used to reformat those three rows, maybe I would know where to add or change certain words if I had to.

    Hope this all makes sense, but I'm really keen on learning how you did it...like asking the magician to disclose his "tricks", lol.

    I appreciate anything you can do to help me understand,

    Jerry
    Attached Files Attached Files

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

    Re: FIND & REPLACE rows of text in an Excel worksheet

    1)
    Don't quote whole posts -- it's just clutter.
    If you are responding to a post out of sequence, limit quoted content to a few relevant lines that makes clear to whom and what you are responding

    For normal conversational replies, try using the QUICK REPLY box below.

    2) No idea what to change. In other words, no need to change as they are the same.

+ Reply to Thread
Page 1 of 2 1 2 LastLast

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