Results 1 to 2 of 2

Thread: Insert Row Excel

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2000
    Location
    N.Ireland
    Posts
    651

    Insert Row Excel

    I need to write a macro which will insert a new row into certain locations within my excel worksheet.

    i.e. if the data in column A's changes i need to insert a new row...

    For example, the first 50 rows in my column A have got the word "Boston". Then Row 51 changes to "New York". When the word changes to new york i need to add on blank row.

    is this possible?
    Gilly

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Insert Row Excel

    Yes.

    Loop from the top to the bottom of your records (how you get the bottom row is up to you but perhaps : sht.cells(65530,1).End(xlUp).Row )
    Hold the current value in a variable.
    If you are on the first/second row (depending on titles etc) then do not add a line otherwise;
    if the current cell is different than the held value
    - store the current cells value
    - insert a row
    - The bottom row (value) should be increased by one
    - the current cell should move down (increment) by one
    If the cell value is the same then move on to the next one

    post up once you've tried some code (if it doesn't work)

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width