+ Reply to Thread
Results 1 to 10 of 10

Insert Row Macro not working all of a sudden...

  1. #1
    Registered User
    Join Date
    04-05-2012
    Location
    Southfield, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    63

    Insert Row Macro not working all of a sudden...

    Hi,

    I've used the following macro hundreds of times with no problem until today...


    Sub InsertRowAtChangeInValue()
    Dim lRow As Long
    For lRow = Cells(Cells.Rows.Count, "B").End(xlUp).Row To 2 Step -1
    If Cells(lRow, "B") <> Cells(lRow - 1, "B") Then Rows(lRow).EntireRow.Insert
    Next lRow
    End Sub


    The macro looks in column B and whenever the value in the following row is different than the value in the previous row, it inserts a row.

    so...

    Bob
    Bob
    Bob
    John
    John
    Amy
    Sarah
    Sarah

    Becomes...

    Bob
    Bob
    Bob

    John
    John

    Amy

    Sarah
    Sarah
    ...


    I've used it in the exact same workbook for I don't know how long...

    Now, all of a sudden, whenever I run it I get a "Runtime Error 13: Type Mismatch"

    I've looked and looked and tried to figure this out to no avail.

    Can anyone out there take a look at this?

    Thanks!

    R.J.

  2. #2
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Insert Row Macro not working all of a sudden...

    Try this and see what happens.

    Please Login or Register  to view this content.

  3. #3
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Insert Row Macro not working all of a sudden...

    Hi R.J.,

    Take a hard look atyour data
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  4. #4
    Registered User
    Join Date
    04-05-2012
    Location
    Southfield, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Insert Row Macro not working all of a sudden...

    Quote Originally Posted by stnkynts View Post
    Try this and see what happens.

    Please Login or Register  to view this content.
    Hi stnkynts,

    I tried your macro and I get that msg box in case of an error that says "Type Mismatch".

    No idea what's going on...

  5. #5
    Registered User
    Join Date
    04-05-2012
    Location
    Southfield, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Insert Row Macro not working all of a sudden...

    Quote Originally Posted by xladept View Post
    Hi R.J.,

    Take a hard look atyour data
    the data is the same as it always is. It's just a bunch of email addresses.

    It splits the prefix from the domain using the @ sign.

    so [email protected] becomes

    Col A Col B
    Row1 jsmith abc.com

    and so on and so on.

    Nothing out of the ordinary. Now, it does have 9000 rows, so I can't check every one of course.

  6. #6
    Forum Expert
    Join Date
    07-31-2010
    Location
    California
    MS-Off Ver
    Excel 2007
    Posts
    4,070

    Re: Insert Row Macro not working all of a sudden...

    Submit a redacted version of your workbook

  7. #7
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Insert Row Macro not working all of a sudden...

    Yeah,

    Attach a sample workbook. 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 use the paperclip icon to open the upload window.

    View Pic

  8. #8
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Insert Row Macro not working all of a sudden...

    I guess you have a formula resulting in an error in one of the cells.
    For example a #N/A.
    Last edited by scottiex; 02-28-2015 at 01:59 AM.

  9. #9
    Registered User
    Join Date
    04-05-2012
    Location
    Southfield, Michigan
    MS-Off Ver
    Excel 2003
    Posts
    63

    Re: Insert Row Macro not working all of a sudden...

    Quote Originally Posted by scottiex View Post
    I guess you have a formula resulting in an error in one of the cells.
    For example a #N/A.
    @scottiex...

    Thank you, you wonderful, wonderful excel person you! lol

    2 "#VALUE"'s in 9,000 rows...

    deleted them and it worked fine.

    @xladept: Thank you for the instructions. I was wondering how to do that...

  10. #10
    Forum Expert
    Join Date
    04-01-2013
    Location
    East Auckland
    MS-Off Ver
    Excel 365
    Posts
    1,343

    Re: Insert Row Macro not working all of a sudden...

    Thanks, I appreciate the feedback

+ 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. [SOLVED] Sudden appearance of Run-time error '13': Type mismatch in previously working code
    By Rhudi in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-22-2014, 11:30 PM
  2. [SOLVED] Paste Special (values) not working all of a sudden?
    By whispers in forum Excel General
    Replies: 26
    Last Post: 08-02-2013, 02:46 PM
  3. All of a sudden, references stoppped working?
    By SaraJZ in forum Excel General
    Replies: 0
    Last Post: 03-12-2008, 10:29 AM
  4. [SOLVED] subtotal-All of a sudden my subtotals aren't working - why?
    By rachel in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 08-07-2006, 02:05 PM
  5. [SOLVED] All of a sudden none of my Excel formulas are working...
    By Trina in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-08-2006, 03:50 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