ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Entering a row everytime column C changes value (https://www.excelbanter.com/excel-discussion-misc-queries/68445-entering-row-everytime-column-c-changes-value.html)

aashish

Entering a row everytime column C changes value
 
I need help creating a macro that will insert a row everytime a value in
column C does not equal the one before it. My data set can be 1000+ rows, so
doing this manually is a bit mind-numbing. I could also set up may data so
that a 0 or 1 is indicated every row that needs to have a row inserted.

thanks in advance.

Don Guillett

Entering a row everytime column C changes value
 
try this. the key is working from the bottom up instead of the top down.

Sub insertrowifnotminusonerow()
lr = Cells(Rows.Count, "c").End(xlUp).Row
For i = lr To 2 Step -1
If Cells(i - 1, "c") < Cells(i, "c") Then Rows(i).Insert
Next i
End Sub

--
Don Guillett
SalesAid Software

"aashish" wrote in message
...
I need help creating a macro that will insert a row everytime a value in
column C does not equal the one before it. My data set can be 1000+ rows,
so
doing this manually is a bit mind-numbing. I could also set up may data
so
that a 0 or 1 is indicated every row that needs to have a row inserted.

thanks in advance.





All times are GMT +1. The time now is 01:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com