ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   how do I create a macro to auto insert rows? (https://www.excelbanter.com/excel-worksheet-functions/68359-how-do-i-create-macro-auto-insert-rows.html)

aashish

how do I create a macro to auto insert rows?
 
I have a 1000+ list and i want to enter a blank row after each entry that
does not equal the prior one. The repeated entries are not evenly spaced.
Can a macro look at a value, determine if it's equal to the prior, and if
not, insert a row?

thanks.

Gary''s Student

how do I create a macro to auto insert rows?
 
Try this:


Sub Macro1()
For i = 1 To 40
j = i + 1
If Not (Cells(i, 1) = Cells(j, 1)) Then
Rows(j).Select
Selection.Insert
i = i + 1
End If
Next
End Sub

--
Gary''s Student


"aashish" wrote:

I have a 1000+ list and i want to enter a blank row after each entry that
does not equal the prior one. The repeated entries are not evenly spaced.
Can a macro look at a value, determine if it's equal to the prior, and if
not, insert a row?

thanks.



All times are GMT +1. The time now is 11:20 AM.

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