none
NEED HELP WITH EXCEL 2013 VBA!! RRS feed

  • Question

  • Hi:

    I'm a database developer who knows Access VBA.  Excel VBA, very little.

    This is what I need to do:

    1) On a worksheet, go to last row - 1 (second to last row)  [blanks have already been deleted]

    2) COPY

    3) CUT

    4) INSERT CUT ROW into Row 12

    Probably very simple but all this positional stuff is a mystery to me.

    Thanks!


    A. Wolf

    Thursday, January 29, 2015 11:27 PM

Answers

  • Like this:

    Sub CutNInsert()
        Dim cel As Range
        ' Find cell in the last used row
        Set cel = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
        ' Cut the row above it
        cel.Offset(-1).EntireRow.Cut
        ' Insert in row 12
        Range("A12").Insert
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by amywolfie Friday, January 30, 2015 7:17 PM
    Friday, January 30, 2015 12:19 AM

All replies

  • Like this:

    Sub CutNInsert()
        Dim cel As Range
        ' Find cell in the last used row
        Set cel = Cells.Find(What:="*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
        ' Cut the row above it
        cel.Offset(-1).EntireRow.Cut
        ' Insert in row 12
        Range("A12").Insert
    End Sub


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    • Marked as answer by amywolfie Friday, January 30, 2015 7:17 PM
    Friday, January 30, 2015 12:19 AM
  • Thanks Hans!

    This solution worked great.


    A. Wolf

    Friday, January 30, 2015 7:17 PM