Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Spreadsheets (https://www.askmehelpdesk.com/forumdisplay.php?f=395)
-   -   Macro in an if statement (https://www.askmehelpdesk.com/showthread.php?t=415695)

  • Nov 13, 2009, 01:27 PM
    fbg3
    Macro in an if statement
    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?
  • Nov 14, 2009, 11:04 AM
    JBeaucaire

    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.

    Code:

    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


  • All times are GMT -7. The time now is 01:06 PM.