+ Reply to Thread
Results 1 to 5 of 5

Macro to remove rows

Hybrid View

  1. #1
    Registered User
    Join Date
    10-02-2006
    Posts
    2

    Macro to remove rows

    Hi all!
    I have a sheet that I need to remove 4 rows over and over again for instance...
    First row has needed data
    The next four rows need to be deleted.
    Sixth row has needed data
    The next four rows need to be deleted.
    Etc.

    Is there a way to write a macro to take care of this? I am EXTREMELY new and unskilled in macros and/or VBA code so any help would be helpful.

    Thanks,
    horsey

  2. #2
    Forum Contributor starryknight64's Avatar
    Join Date
    09-27-2006
    Location
    Missouri
    MS-Off Ver
    2003 (Work) & 2007 (Home)
    Posts
    193
    Give this a shot. Just run this macro until you are satisfied with what was deleted. Make sure you type "No" (with a capital "N") to quit the macro.

    Sub delete_em()
    
    Dim yesno As String
    Dim row As Integer
    
    yesno = "Yes"
    row = 1
    
        While yesno = "Yes"
            Rows(row + 1 & ":" & row + 4).Select
            Selection.Delete Shift:=xlUp
            yesno = InputBox("Continue? Type Yes or No.", , "Yes")
            row = row + 1
        Wend
    End Sub
    If you have any questions, please let me know! Good luck.
    starryknight64

  3. #3
    Registered User
    Join Date
    10-02-2006
    Posts
    2

    Thumbs up Awsome Advice

    That worked GREAT. Once I saw that it would do what I needed it to do I even learned how to make it loop to take care of all of my records (around 5000).

    Again since I am EXTREMELY new to all of the macros and VBA can you suggest a good book(s), site(s), or teaching program(s) to learn from to become fluent?

    Thanks SO much for your help.
    Horsey

  4. #4
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Horsey,

    There are a few good EXCEL PROGRAMMING books out there but imo, the near best for a starter is John Walkenbach's book on Power Programming. See Link:
    http://j-walk.com/ss/books/index.htm.

    To fast-track your learning, it cannot be emphasized too strongly that the web EXCEL NEWSGROUPS offer a rich resource to complement textbook stuff. Avail yourself of the exposure to current thrust of forum discussions. And it is good news that there are limitless archival data and information bank you can always trawl through using google search.

    Finally, remember the good old adage: practice makes perfect.
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

  5. #5
    Forum Contributor starryknight64's Avatar
    Join Date
    09-27-2006
    Location
    Missouri
    MS-Off Ver
    2003 (Work) & 2007 (Home)
    Posts
    193
    Wow! I'm glad it was a great help!

    To tell you the truth, to hone my programming skills, I do this! That is, I help people in these forums with any knowledge I have of programming and/or excel. It keeps me busy and I'm helping people. I enjoy it thoroughly.

+ 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