Insert cell from an if statement

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a worksheet that I want an if statement that says if one cell =
another, then do nothing, otherwise insert a blank cell. Is there a way to do
this???
 
If you mean physically insert a new cell, as in use the menu to Incert | Cell
and then choose Shift Right/Down, then the answer is that it can be done, but
would have to be done with a macro.
 
I'm not sure how it would work with a macro. I am comparing two cells and if
they match then nothing happens, if they don't match, then the statement
would force a new cell to be entered, thus shifting the cells below down.
 
Sub foo()
With ActiveSheet
If Range("A2").Value <> Range("A1").Value Then
Range("A2").Offset(1, 0).Insert Shift:=xlDown
End If
End With
End Sub


Gord Dibben MS Excel MVP
 
Back
Top