Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 190
Default delete alternate column

How can I delete every other column (B, D, F.....) in Excel?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to delete alternate rows in a spreadsheet? SI New Users to Excel 3 April 17th 08 10:19 AM
reformating data- how to delete alternate blank rows quickly datamanipulator Excel Discussion (Misc queries) 4 November 27th 07 04:41 PM
is there a way to delete alternate rows in excel Martin R Excel Discussion (Misc queries) 4 October 8th 07 04:57 PM
Delete a group of alternate cells poleary53 New Users to Excel 1 March 7th 06 11:05 PM
Can I add a description column or alternate column in a validation Spongebob Excel Programming 4 April 6th 05 06:17 PM


All times are GMT +1. The time now is 11:07 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"