PC Review


Reply
Thread Tools Rate Thread

delete alternate column

 
 
mary
Guest
Posts: n/a
 
      24th Jul 2008
How can I delete every other column (B, D, F.....) in Excel?
 
Reply With Quote
 
 
 
 
marcus
Guest
Posts: n/a
 
      25th Jul 2008
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
 
Reply With Quote
 
OssieMac
Guest
Posts: n/a
 
      25th Jul 2008
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
>

 
Reply With Quote
 
Gary Keramidas
Guest
Posts: n/a
 
      25th Jul 2008
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" <(E-Mail Removed)> wrote in message
news:01D920CE-D28B-40B0-8779-(E-Mail Removed)...
> How can I delete every other column (B, D, F.....) in Excel?



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternate Rounding Up & Down of .50 in a column HunterX Microsoft Excel Worksheet Functions 5 2nd Jun 2010 04:55 PM
Add alternate cells in column and sum Jackanorry Microsoft Excel Worksheet Functions 4 23rd Mar 2008 06:28 PM
How can I choose alternate rows in a column? =?Utf-8?B?cG5haXI=?= Microsoft Excel New Users 2 17th Dec 2005 05:16 AM
Can I add a description column or alternate column in a validation =?Utf-8?B?U3BvbmdlYm9i?= Microsoft Excel Programming 3 6th Apr 2005 06:17 PM
delete alternate columns... Microsoft Excel Worksheet Functions 5 17th Nov 2003 02:39 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:56 PM.