MACRO every 2nd Coulm want delete in selection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello,
I want creat a macro which i want use delete my selection every second coulm.

A_col B_col C_col
1
2 <----- want delete
3
4 <------want delete
5
Thanks/Tufail
 
Hi Tufail,

Try:
'================>>
Public Sub Tester()
Dim rng As Range
Dim delRng As Range
Dim i As Long
Dim CalcMode As Long

Set rng = Selection '<<==== CHANGE

On Error GoTo XIT
With Application
CalcMode = .Calculation
.Calculation = xlCalculationManual
.ScreenUpdating = False
End With

For i = 2 To rng.Rows.Count Step 2
If delRng Is Nothing Then
Set delRng = rng.Rows(i)
Else
Set delRng = Union(rng.Rows(i), delRng)
End If
Next i

If Not delRng Is Nothing Then
delRng.EntireRow.Delete
End If

XIT:
With Application
.Calculation = CalcMode
.ScreenUpdating = True
End With

End Sub
'<<================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top