This is the updated code
Option Explicit
Sub update_status()
Dim lrow As Long, i As Long, a As Long
With Worksheets("Status")
lrow = .Range("B" & .Rows.Count).End(xlUp).Row
For i = 4 To lrow
If .Range("B" & i).Value <> "Risk" Then
.Range("B" & i).Value = ""
End If
Next i
End With
a = 4
With Worksheets("Issue Log")
lrow = .Range("C" & .Rows.Count).End(xlUp).Row
For i = 3 To lrow
If .Range("G" & i).Value = "Open" And .Range("H" & i).Value = "Critical" Then
If Worksheets("Status").Range("B" & a + 2).Value = "Risk" Then
Worksheets("Status").Rows(a).Insert
End If
Worksheets("Status").Range("B" & a).Value = .Range("D" & i).Value
a = a + 1
End If
Next i
End With
With Worksheets("Status")
lrow = .Range("B" & .Rows.Count).End(xlUp).Row
For i = 4 To lrow
If .Range("B" & i).Value = "Risk" Then
a = i + 1
Exit For
End If
Next i
End With
With Worksheets("Risk Tracker")
lrow = .Range("C" & .Rows.Count).End(xlUp).Row
For i = 3 To lrow
If .Range("G" & i).Value = "Critical" And .Range("I" & i).Value = "Open" Then
If Worksheets("Status").Range("B" & a + 1 & ":M" & a + 1).MergeCells = False Then
Worksheets("Status").Rows(a).Insert
End If
Worksheets("Status").Range("B" & a).Value = .Range("D" & i).Value
a = a + 1
End If
Next i
End With
End Sub
Observations
The reason why the wrong format was duplicating was because of some unmerged cells after row 13. Ensure that the rows required to be merged are merged properly.
If you want to duplicate the code for Action Items, just copy this part of the code again
With Worksheets("Status")
lrow = .Range("B" & .Rows.Count).End(xlUp).Row
For i = 4 To lrow
If .Range("B" & i).Value = "Risk" Then
a = i + 1
Exit For
End If
Next i
End With
With Worksheets("Risk Tracker")
lrow = .Range("C" & .Rows.Count).End(xlUp).Row
For i = 3 To lrow
If .Range("G" & i).Value = "Critical" And .Range("I" & i).Value = "Open" Then
If Worksheets("Status").Range("B" & a + 1 & ":M" & a + 1).MergeCells = False Then
Worksheets("Status").Rows(a).Insert
End If
Worksheets("Status").Range("B" & a).Value = .Range("D" & i).Value
a = a + 1
End If
Next i
End With
Make the required corrections like changing
If .Range("B" & i).Value = "Risk" Then
to
If .Range("B" & i).Value = "Action" Then
Bookmarks