+ Reply to Thread
Results 1 to 5 of 5

Simple macro to conditionally insert a row?

  1. #1
    Forum Contributor
    Join Date
    10-05-2005
    Posts
    112

    Question Simple macro to conditionally insert a row?

    Hi,

    I have quite a large data set which has frequent missing lines in that the data should be every 5 minutes but every hour there is at least one 5 minute slot missed - would it be possible to seek help writing a macro to do the following for the data example below IE to fix the missing row between 7 & 8:

    - Compare each cell in column B to the value above.
    - IF the difference is =10 minutes rather than 5 minutes.
    - THEN insert a blank row, copy the time value down into the empty cell in column B adding 5 minutes, copy the value down from the cell above in columns A, C, D.....N into the blank cells of the new row.
    - REPEAT until the end of the data - in this case 130,000 rows

    Many thanks for any helping minds.

    Please Login or Register  to view this content.

  2. #2
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Simple macro to conditionally insert a row?

    Here, try this:
    Please Login or Register  to view this content.
    1. Include a sample workbook with an example of the result you want
    2. Use [CODE] and [FORMULA] wrappers for your VBA code or excel formulas
    3. If your question has been answered, mark the thread as SOLVED and click on the "Add Rep" star to thank whoever helped you.

  3. #3
    Forum Contributor
    Join Date
    10-05-2005
    Posts
    112

    Re: Simple macro to conditionally insert a row?

    Hi K64,

    Many, many thanks for your help on this - very much appreciated.

    I have run the code but getting a 'Runtime Error 13' Type Mismatch on this line?

    Please Login or Register  to view this content.
    Probably something I have done wrong?

  4. #4
    Forum Contributor
    Join Date
    10-05-2005
    Posts
    112

    Re: Simple macro to conditionally insert a row?

    Hi K64,

    I have compiled a test SS - attached - to see if it works for you - I'm still stuck on the type mismatch :-)

    Insert5mins.xlsm

  5. #5
    Valued Forum Contributor
    Join Date
    08-06-2013
    Location
    Detroit, Michigan
    MS-Off Ver
    Excel 2013
    Posts
    671

    Re: Simple macro to conditionally insert a row?

    Your new data has headers. Also, you're using empty cells at the bottom. Highlight all rows beneath your data and delete the entire row so that the used range is just your data. Try this code
    Please Login or Register  to view this content.

+ 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. Macro to insert rows conditionally.
    By HarryC23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 04-10-2014, 06:36 AM
  2. [SOLVED] Simple macro to insert a new row if 2 numbers exceeding 99999999 are next to each other
    By ostego in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 02-26-2014, 07:26 AM
  3. Insert Rows Conditionally
    By samsonuk in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 09-19-2013, 07:06 PM
  4. [SOLVED] Macro to conditionally insert rows and fill them
    By dproth in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-10-2013, 09:48 AM
  5. [SOLVED] Need Simple Copy and Insert Row, Move Down Macro
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 02-24-2006, 12: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