+ Reply to Thread
Results 1 to 3 of 3

Help Needed Fixing Loop for Replacing Text

  1. #1
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Help Needed Fixing Loop for Replacing Text

    I'm trying to write a macro that searches for the string " Total" in a column of text and once it finds that text, replaces it with "" and performs a variety of functions around that cell including adding rows above and below and formatting cells around it before searching for the next iteration of " Total". The code works fine until there are no more instances of " Total" to be found, at which point the macro stops and I receive the error "Run-time error '91': Object variable or With block variable not set."

    I've searched online for a solution to why this isn't working in my macro, but can't find the right combination of code to make my macro work. The pertinent part of my code is below. (The lines showing just a period are used to dramatically shorten the code.)

    Please Login or Register  to view this content.
    Last edited by bryanmarks; 04-29-2014 at 05:00 PM.

  2. #2
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Help Needed Fixing Loop for Replacing Text

    I still need help! Also, I can't figure out how to delete this post (my second post). I can only seem to edit it, not delete it. Sorry!
    Last edited by bryanmarks; 04-28-2014 at 05:25 PM.

  3. #3
    Registered User
    Join Date
    04-14-2014
    Location
    Atlanta, GA, USA
    MS-Off Ver
    Excel 2016
    Posts
    46

    Re: Help Needed Fixing Loop for Replacing Text

    Sorry to keep asking, but if anyone can help me with this code so that it moves on and ignores the fact that the search string is not found, it would be greatly appreciated! I've spent hours trying to debug this. My only workaround now is to run the macro separately on each worksheet, wait for it to hit the Error message, then click on the next macro to finish that worksheet before continuing to the next worksheet.

+ 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. IF function: Using text in logical_test with multiple variables and replacing with text
    By SarahRachelJones in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 11-25-2012, 02:17 PM
  2. [SOLVED] replacing nested if statements with some kind of VBA loop?
    By cwyn in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 10-27-2012, 01:46 PM
  3. Replies: 6
    Last Post: 07-06-2006, 04:15 PM
  4. Help needed replacing multiple cells from a list of values.
    By Emoshag in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-06-2006, 12:35 PM

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