Log in

View Full Version : Macro in an if statement


fbg3
Nov 13, 2009, 01:27 PM
I have a large list of names that I need to separate by inserting a new row after each client. How can I build a macro into an if statement and/or a vlookup?

JBeaucaire
Nov 14, 2009, 11:04 AM
You can't. And you can't make physical changes to your layout with a formula either, only with a macro.

If all you want to do is go down one column and add a blank row between every existing row of data, this macro will do it. It uses column A.


Sub InsertRows()
'JBeaucaire (11/14/2009)
Dim LR As Long, i As Long
Application.ScreenUpdating = False
LR = Range("A" & Rows.Count).End(xlUp).Row

For i = LR To 2 Step -1
Rows(i).Insert xlShiftDown
Next i

Application.ScreenUpdating = True
End Sub