delete alternate rows in ms excel

Hi friends ,in this post I am sharing how to delete alternate rows in ms excel .In ms excel sometimes we need to delete alternate rows which will same time for us .And this concept is also used to delete duplicate rows also.In excel there was many options available but to delete alternate rows you need to do a small work.

 

 

 

delete-altenate-rows-excel

 

 

  • First of all we need to enable developer tab.In most of the situations initially developer tab was not added to the menu in ms excel.

How to show developer tab in excel menu? 

  • Goto MSexcel.I am using MS excel 2007
  • Next in the home tab right click on the ribbon  region.Some ribbon region are clipboard ,font,alignment and more.For example I am right clicking on clipboard.
  • In that click “customize quick access toolbar”.A popup windows appears.This popup windows is called as excel options.Under that choose “Popular”.Make tick in the box of “Show developer tab in the ribbon”
  • Now nearer “View Tab” you can see “Developer Tab”.

A demo of ”how to enable developer tab in excel menu”

 

show-developer-tab-demo

 

how to delete alternate rows?

  • Goto MSexcel.I am using MS excel 2007
  • I am saying with an example .With the example you can understand how to apply in your sheets .In the “A column”at “A1” enter number ”1” and drag upto 10 rows.Now right click on it then click “fill series”.Then it will automatically fill the numbers in series like ,

1

2

3

4

5

6

.

.

.

Be sure you should select these values,otherwise it will not work

  • Now click developer tab.Next click Visual basic . A new window opens ,in that click click “insert” and choose “module”.Now another window opens on right side.In that region copy and paste the below code.

Sub Delete_Every_Other_Row()

   ' Dimension variables.
   Y = False              ' Change this to True if you want to
                          ' delete rows 1, 3, 5, and so on.
   I = 1
   Set xRng = Selection

   ' Loop once for every row in the selection.
   For xCounter = 1 To xRng.Rows.Count

       ' If Y is True, then...
       If Y = True Then

           ' ...delete an entire row of cells.
           xRng.Cells(I).EntireRow.Delete

       ' Otherwise...
       Else

           ' ...increment I by one so we can cycle through range.
           I = I + 1

       End If

       ' If Y is True, make it False; if Y is False, make it True.
       Y = Not Y

   Next xCounter

End Sub

  • Now return to excel and click developer tab.Click macros.Macro window open and it shows “Delete_Every_Other_Row” just click run.In simple,the selected row and its alternates will be saved,others will be deleted.  Now if your first row selected is even row  odd rows will be deleted.And if you selected first row as odd row,even rows will be deleted.
  • A sample

delete-alternate-rows-demo1

 

Another sample,

 

 

delete-alternate-rows-demo2

Print Friendly and PDF
SHARE

About me

Hi. I am interested in blogging.And sometimes play with webdesign,web development,domain sale,designing logo and more.

    Blogger Comment
    Facebook Comment

0 comments :

Post a Comment