Microsoft Excel Question

Discussion in 'Black Hat SEO' started by MyHub, Mar 4, 2012.

  1. MyHub

    MyHub Regular Member

    Joined:
    Feb 9, 2010
    Messages:
    208
    Likes Received:
    32
    Hi, How do I delete every other row? For example

    1 fred
    2 bob
    3 susan
    4 billy
    5 john
    6 larry
    7 allen
    8 daniel
    9 kevin

    I want to delete all the odd rows. How do I do that without doing them individually. I know there's a way, I just can't think of it.
     
  2. kvmcable

    kvmcable Supreme Member

    Joined:
    Dec 28, 2010
    Messages:
    1,354
    Likes Received:
    2,820
    Occupation:
    24 year business owner - old school dude
    Location:
    KFC - BW3
    Google and download ASAP utilities. When you get it installed find Rows and Columns and selelct Conditional row and column select, hide delete. From there it's intuitive.

    Good luck
     
    • Thanks Thanks x 1
  3. The SEO

    The SEO Jr. VIP Jr. VIP

    Joined:
    Dec 14, 2011
    Messages:
    4,499
    Likes Received:
    3,266
    Gender:
    Male
    Occupation:
    SEO/SMM
    Location:
    BHW
    Home Page:
    Select the rows----right click on the selected rows----click on delete
     
  4. thinkdevoid

    thinkdevoid Regular Member

    Joined:
    Aug 30, 2011
    Messages:
    449
    Likes Received:
    131
    Location:
    192.168.1.1
    (Macros + VB) = your friend :)



    1) Where you see the menu options (home, insert, page layout, etc). Right click and hit "Customize quick access toolbar".

    2) In the Popular Tab, check off: "Show Developer Tab in Ribbon"

    Note: The above steps are only needed once.



    3) Tab over to the Developer tab and hit "Visual Editor". A new window will pop up.

    4) in The new window, go to the "Insert" menu and hit "Module"

    5) Enter in the following code:

    Code:
    Sub DeleteOtherRows()
       deleteOdd = False
       x = 1
       Set xRng = Selection
       For Counter = 1 To xRng.Rows.Count
           If deleteOdd = True Then
               xRng.Cells(x).EntireRow.Delete
           Else
               x = x + 1
           End If
           deleteOdd = Not deleteOdd
       Next Counter
    End Sub
    
    
    Note: To delete odd numbers, set deleteOdd = False to deleteOdd = True.

    6) Save. Note: To keep these macros permanent, you'll want to save it as a macro-enabled file.

    7) Back in your sheet, select the rows you want to remove. Warning: Do NOT select all the rows by the column letter -> this will result in an near-endless loop.

    8) go to the dev tab, hit macro, hit run.
     
    Last edited: Mar 4, 2012