Excel Macro ??

  dobie2 18:49 10 Feb 10
Locked

Guys

I have a spreadsheet full of data, 16000+ lines which I need to manipulate.

I need one of two solutions to the problem.

1 Is it possible to delete every even numbered row easily.

2. Or, is it possible to add all the even numbered rows of data to the end of the odd numbers.

Love

Debs

  VoG II 19:13 10 Feb 10

1. is easier


Sub DelEven()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
LR = ActiveSheet.UsedRange.Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
For i = LR To 2 Step -1
If i Mod 2 = 0 Then Rows(i).Delete
Next i
Application.ScreenUpdating = True
End Sub

  VoG II 19:44 10 Feb 10

2.

Sub MoveEven()
Dim LR As Long, i As Long, ws1 As Worksheet, ws2 As Worksheet
Application.ScreenUpdating = False
Set ws1 = ActiveSheet
Set ws2 = Worksheets.Add
With ws1
LR = .UsedRange.Find("*", SearchDirection:=xlPrevious, SearchOrder:=xlByRows).Row
For i = 2 To LR
If i Mod 2 = 0 Then .Rows(i).Cut Destination:=ws2.Range("A" & Rows.Count).End(xlUp).Offset(1)
Next i
ws2.UsedRange.Copy Destination:=.Range("A" & Rows.Count).End(xlUp).Offset(1)
.Columns("A").SpecialCells(xlCellTypeBlanks).EntireRow.Delete
End With
Application.DisplayAlerts = False
ws2.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…