Tuesday 15 February 2011

Excel VBA Macro to add a row when value changes and populate that row -


I am trying to create a macro in Excel which will take a bunch of data like this:

  D 1 2 3 4 5D 1 2 3 9 5D 1 2 3 4 5   

and if the value is different in column 4, then insert a line Process for I also want to populate this line with static values ​​or a formula at the same time.

So ideally, take up the table above me:

  D 1 2 3 4 5 HBBCE and LT; - This row was added because there was a change in the column DD132395; - This row was added because it changed the column DD to 1 2 3 4 5   

I want to redo it through a very long list.

Can someone give me any sign?

Thank you for your help.

There should be something like this that I did not test it but if you run it and again it If you use F8 to run again, it should be easy to debug, if it does not work properly.

  cells from 2 (1,1) .end (xldown). Iterate 'ifres (i, 4) through all the rows .value & lt; & Gt; Cells (i-1,4). Then compare the cells in Column 4 with the previous lines (4) of the properties' rows. If 'cell' (i, 1) does not match 'a' then insert the line. Cells (i, 2) = "B" cells (i, 3) = "C" cells (i, 4) = "D" cells (i, 5) = "e" i = i + 1 ' Make me bigger to finish    

No comments:

Post a Comment