Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete alternate column
How can I delete every other column (B, D, F.....) in Excel?
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete alternate column
Hi Mary
This will delete every second column in your sheet. Take care marcus Sub RemCol() Dim Col As Integer Col = 2 Application.ScreenUpdating = False For i = Col To 256 Step 2 Cells(1, Col).EntireColumn.Delete Next i End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete alternate column
I think that Marcus' code will delete all columns except column 1. You need
to work backwards when deleting columns or rows. Try this modification Sub RemCol() Dim Col As Integer Col = 2 Application.ScreenUpdating = False For i = 256 To Col Step -2 Cells(1, i).EntireColumn.Delete Next i End Sub -- Regards, OssieMac "marcus" wrote: Hi Mary This will delete every second column in your sheet. Take care marcus Sub RemCol() Dim Col As Integer Col = 2 Application.ScreenUpdating = False For i = Col To 256 Step 2 Cells(1, Col).EntireColumn.Delete Next i End Sub |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
delete alternate column
one way
Sub test() Dim lastcol As Long Dim ws As Worksheet Set ws = Worksheets("Sheet1") lastcol = ws.Cells(1, Columns.Count).End(xlToLeft).Column For i = lastcol To 1 Step -1 If i Mod 2 = 0 Then Columns(i).Delete End If Next End Sub -- Gary "mary" wrote in message ... How can I delete every other column (B, D, F.....) in Excel? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how to delete alternate rows in a spreadsheet? | New Users to Excel | |||
reformating data- how to delete alternate blank rows quickly | Excel Discussion (Misc queries) | |||
is there a way to delete alternate rows in excel | Excel Discussion (Misc queries) | |||
Delete a group of alternate cells | New Users to Excel | |||
Can I add a description column or alternate column in a validation | Excel Programming |