LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 397
Default Deleting evey nth column

HI there,

A tough one I think...

I would like to keep column A,B,C.
Then delete Column D,E,F, keep column G
Then delete column h,i,j keep column K
Then delete column l,m,n keep column O, etc etc till I run out of
columns.

I was previously helped with a SIMILAR problem (the movement of the
number of columns was different and the VB below worked for me, however
I dont know how to change it to achieve what I want to achieve above.
Any ideas????

Sub go_delete()
Dim tmp As Integer
Dim tmp2 As Integer
Dim tmp_address As String, row_count As Single

With ActiveSheet.UsedRange
tmp = Fix((.Columns.Count - 5) / 4)
If (.Columns.Count - 5) Mod 4 0 Then
tmp = tmp + 1
End If
tmp_address = .Address(False, False)
row_count = .Rows.Count
End With
With ActiveSheet.Range(tmp_address)
With .Offset(0, 5).Resize(row_count, .Columns.Count - 5)
For tmp2 = tmp To 1 Step -1
With .Columns(4 * tmp2 - 3)
.Resize(row_count, 2).EntireColumn.Delete
End With
Next
End With
End With
End Sub




*** Sent via Developersdex http://www.developersdex.com ***
 
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 can make a macro to run evey one hour-automatically SAM SEBAIHI Excel Discussion (Misc queries) 2 January 30th 07 04:12 AM
Auto Refresh evey ?? in a linked list Graham Excel Discussion (Misc queries) 0 July 27th 06 12:06 PM
Deleting cells in a column ref a different column Daminc[_23_] Excel Programming 8 December 23rd 05 05:04 PM
Deleting a row by a column value DKY[_17_] Excel Programming 2 October 8th 04 01:33 AM
Deleting a row with 0 in column A Steven R. Berke Excel Programming 1 October 2nd 03 01:37 AM


All times are GMT +1. The time now is 05:20 PM.

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

About Us

"It's about Microsoft Excel"