+ Reply to Thread
Results 1 to 18 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 Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,444

    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
    729

    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 O.365
    Posts
    22,516

    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 O.365
    Posts
    22,516

    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
    729

    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 O.365
    Posts
    22,516

    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 O.365
    Posts
    22,516

    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.

  16. #16
    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

    Thanks for the tips!

    I'm just asking you to take a look at the code you wrote and perhaps help me understand.

    The first "SAMPLE BEFORE.xlsx" is the original spreadsheet.

    The second "SAMPLE AFTER.xlsx" is the spreadsheet which was changed by your macro (if you notice your macro successfully changed three rows).

    My question is, would you mind looking at the code you wrote and perhaps place some comment lines within the code to help me understand what each of the lines accomplishes.

    It all works so well and I'm just trying to understand the meaning of the lines of code.

    Very sorry to bother you about this,

    Regards,

    Jerry

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

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

    OK.

    I don't know if it helps, as I don't know how deep you know about vba/Excel.

    Please Login or Register  to view this content.

  18. #18
    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

    Thanks again jindon,

    My knowledge of vba/Excel is now quite limited as I've forgotten much of it over the years...one of the symptoms of age, lol.

    I do appreciate the comment lines and tomorrow I'll go through each line to see if I can figure it out.

    Thanks so much for all you've done,

    Jerry

+ 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. Excel Find and Replace part of text in cell with a meaning from another worksheet
    By jiwaniakbar in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-14-2013, 04:21 PM
  2. Replies: 5
    Last Post: 08-21-2013, 10:45 AM
  3. find in excel replace in word: find/replace text in text boxes and headers
    By dean.rogers in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-10-2012, 12:40 PM
  4. Find and Replace Text in Formula on a given worksheet in an excel workbook using VBA
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-08-2012, 08:32 PM
  5. VBA to find and replace many words in rows of text
    By MaverickII in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-17-2011, 09:37 AM
  6. Replies: 7
    Last Post: 03-03-2008, 11:48 AM
  7. Replies: 3
    Last Post: 05-22-2006, 02:25 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