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
- Saints row 2 cheats - Guide
- How to delete a row in a table in word - Guide
- How to insert a checkmark in word - Guide
- How to insert @ in a laptop - Guide
- How to insert a line in word for resume - Guide
1 response
venkat1926
Posts
1863
Registration date
Sunday June 14, 2009
Status
Contributor
Last seen
August 7, 2021
811
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"