Inserting a row when the value of a field changes
Solved/Closed
kkautz
Posts
1
Registration date
Friday April 25, 2014
Status
Member
Last seen
April 25, 2014
-
Apr 25, 2014 at 03:06 PM
KKautz - Apr 28, 2014 at 09:51 AM
KKautz - Apr 28, 2014 at 09:51 AM
Related:
- Inserting a row when the value of a field changes
- Excel auto insert row when data changes ✓ - Excel Forum
- Please insert a disk into sdhc ✓ - Windows Forum
- Excel create unique id for each row ✓ - Excel Forum
- How to delete a row in word - Guide
- How to insert @ on a laptop - Guide
1 reply
venkat1926
Posts
1864
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
810
Apr 26, 2014 at 07:55 AM
Apr 26, 2014 at 07:55 AM
data is like this
hdng1
a
a
a
d
d
d
d
d
d
f
will this macro help
hdng1
a
a
a
d
d
d
d
d
d
f
will this macro help
Sub test()
Dim j As Integer, k As Integer
j = Range("A1").End(xlDown).Row
For k = j To 3 Step -1
If Cells(k, 1) <> Cells(k - 1, 1) Then Cells(k, 1).EntireRow.Insert
Next k
End Sub
Apr 28, 2014 at 09:51 AM
'Insert a new row if the values in either column A or B changes
'Copy the heading to the inserted row
Dim LR As Long, i As Long
LR = Range("B" & Rows.Count).End(xlUp).Row
For i = LR To 5 Step -1
If Range("A" & i).Value <> Range("A" & i - 1).Value Or Range("B" & i).Value <> Range("B" & i - 1).Value Then Rows(i).Insert
Rows("2:2").Select
Selection.Copy
Next i
Range("A1").Select
MsgBox "Done"