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: 113
Default Delete columns based on cell value

Im trying to loop through each cell in the first row of a sheet and if
the cell contains the text "ID" the delete that entire column. the
following code works well except it starts at the 11th column instead
of at the first also the curCell value is blank after a certain number
of cells even tho there is still data in the location it is looking
at.

Sub DeleteIDCol()
'removes the LC_ID and QD_ID columns.
Dim colHead As Range
Dim n As Integer
Dim curCell As Range

Set colHead = Rows(1)
For n = 1 To colHead.Columns.Count
Set curCell = Cells(1 & n)
If InStr(1, curCell, "ID") 0 Then
curCell.EntireColumn.Delete
End If
Next n
End Sub

 
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
Delete Row Based On Two Columns Kris Excel Programming 8 July 6th 06 12:44 AM
Delete Columns based on Strings scott Excel Programming 2 January 18th 05 12:43 AM
How can I delete a row based on Columns H and I ICSAnalyst[_3_] Excel Programming 1 November 16th 04 10:19 AM
How can I delete a row based on Columns H and I ICSAnalyst[_4_] Excel Programming 1 November 15th 04 09:15 PM
Delete Columns based on a condition Joel Mills Excel Programming 3 August 6th 04 07:21 PM


All times are GMT +1. The time now is 03:06 AM.

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"