Prevost
Board Regular
- Joined
- Jan 23, 2014
- Messages
- 198
Hi there,
I am trying to make a macro to insert a row between different numbers. I would like the if statement to end if either of the first two conditions are met. I do not want to exit the entire macro though. Can someone help me please? Thanks.
I am trying to make a macro to insert a row between different numbers. I would like the if statement to end if either of the first two conditions are met. I do not want to exit the entire macro though. Can someone help me please? Thanks.
Code:
Sub AddRow()
Dim Cell As Range
For Each Cell In Selection
If Cell.Offset(1, 0).Value = vbNullString Then
'exit if statement and go onto next cell
ElseIf Cell = vbNullString Then
'exit if statement and go onto next cell
If Cell <> Cell.Offset(1, 0).Value Then
Cell.Offset(1, 0).EntireRow.Insert
End If
Next Cell
End Sub