View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.misc
Leith Ross
 
Posts: n/a
Default Cutting every other row from a spreadsheet


Hello Jc40,

First copy the Macro code below using Ctrl + C. With your workbook
open, press Alt + F11 to open the VB Editor. Next insert a standard VBA
Module into your project.

To add a new Module:
Press Alt + I to drop down the Insert menu.
Press M to insert the new Module
Press Ctrl + V to paste the code into the Module
Press Ctrl + S to save the Macro
Press Alt + Q to quit the Editor and return to Excel

To Run the Macro:
Select the worksheet you want to cut in half
Press Alt + F8 to display the Macro List
Click on CutInHalf and press Enter

Macro Code:

Public Sub CutInHalf()

Dim EndRow As Long
Dim StartRow As Long
Dim NewRow As Long
Dim NewWks As Worksheet
Dim OldWks As Worksheet
Dim R As Long

Set OldWks = ActiveSheet
With OldWks.UsedRange
StartRow = .Row
EndRow = .Rows.Count + .Row - 1
End With

ActiveWorkbook.Worksheets.Add After:=OldWks
Set NewWks = ActiveSheet

For R = StartRow To EndRow Step 2
NewRow = NewRow + 1
OldWks.Cells(R, "A").EntireRow.Copy
Destination:=NewWks.Cells(NewRow, "A").EntireRow
Next R

End Sub


Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=546975