+ Reply to Thread
Results 1 to 4 of 4

Macro which deletes rows

Hybrid View

  1. #1
    Registered User
    Join Date
    09-10-2012
    Location
    bath
    MS-Off Ver
    Excel 2010
    Posts
    16

    Macro which deletes rows

    Im looking for a macro which will delete and shift up my data. (Rows 2-12)
    This is probably really simple?

    Thanks

  2. #2
    Forum Moderator jeffreybrown's Avatar
    Join Date
    02-19-2009
    Location
    Cibolo, TX
    MS-Off Ver
    Office 365
    Posts
    10,327

    Re: Macro which deletes rows

    As a beginning step, you could record yourself taking this action and then paste the macro here and we can show you how to clean it up.
    HTH
    Regards, Jeff

  3. #3
    Registered User
    Join Date
    09-10-2012
    Location
    bath
    MS-Off Ver
    Excel 2010
    Posts
    16

    Re: Macro which deletes rows

    Okay thanks,

    So i get
    Sub DeleteRow()
    '
    ' deleterows Macro
    '
    
    '
        ActiveWindow.ScrollColumn = 3
        ActiveWindow.ScrollColumn = 2
        ActiveWindow.ScrollColumn = 1
        Selection.Delete Shift:=xlUp
    End Sub
    Which works after selecting what i want. So i just need to change it by adding in the range i want to delete so it does it automatically?

  4. #4
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,198

    Re: Macro which deletes rows

    Hi, kjshep,

    refer to the range and add EntireRow as otherwise only the cells would get deleted:
    Sub DeleteRow()
    '
    ' deleterows Macro
    '
    
    '
        Range("A2:A12").EntireRow.Delete Shift:=xlUp
    End Sub
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1