PC Review


Reply
Thread Tools Rate Thread

Delete Entire Column

 
 
K
Guest
Posts: n/a
 
      23rd Nov 2010
Hi all, I am trying to delete EntireColumn of Range("I9:BF9") where
cell value in that range is "X". I tried doing it with below code but
I its not deleting all the columns. I think I might need to put
something where it say "i" in line "If Cells(9, i).Value = "X" Then"
and "Cells(9, i).EntireColumn.Delete". But I cant work it out. Please
can any friend can help me on this

Code I am using************

Sub DelCol()
For i = Range("I9:BF9").Columns.Count To 1 Step -1
If Cells(9, i).Value = "X" Then
Cells(9, i).EntireColumn.Delete
End If
Next
End Sub
 
Reply With Quote
 
 
 
 
Roger Govier
Guest
Posts: n/a
 
      23rd Nov 2010
Hi K

Try
Sub DelCol()
Dim i As Long
For i = Range("I9:BF9").Columns.Count + 8 To 9 Step -1
If Cells(9, i).Value = "X" Then
Columns(i).EntireColumn.Delete
End If
Next
End Sub

You need to add 8 (columns(A:G)) to your Count and to your final value to
ensure it is the correct columns you are deleting
--

Regards
Roger Govier

"K" <(E-Mail Removed)> wrote in message
news:9a375f02-e81c-4188-8581-(E-Mail Removed)...
> Hi all, I am trying to delete EntireColumn of Range("I9:BF9") where
> cell value in that range is "X". I tried doing it with below code but
> I its not deleting all the columns. I think I might need to put
> something where it say "i" in line "If Cells(9, i).Value = "X" Then"
> and "Cells(9, i).EntireColumn.Delete". But I cant work it out. Please
> can any friend can help me on this
>
> Code I am using************
>
> Sub DelCol()
> For i = Range("I9:BF9").Columns.Count To 1 Step -1
> If Cells(9, i).Value = "X" Then
> Cells(9, i).EntireColumn.Delete
> End If
> Next
> End Sub
>
> __________ Information from ESET Smart Security, version of virus
> signature database 5641 (20101123) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com
>
>
>


__________ Information from ESET Smart Security, version of virus signature database 5641 (20101123) __________

The message was checked by ESET Smart Security.

http://www.eset.com



 
Reply With Quote
 
K
Guest
Posts: n/a
 
      23rd Nov 2010
On Nov 23, 12:14*pm, "Roger Govier" <ro...@technology4nospamu.co.uk>
wrote:
> Hi K
>
> Try
> Sub DelCol()
> * * Dim i As Long
> * * For i = Range("I9:BF9").Columns.Count + 8 To 9 Step -1
> * * * * If Cells(9, i).Value = "X" Then
> * * * * * * Columns(i).EntireColumn.Delete
> * * * * End If
> * * Next
> End Sub
>
> You need to add 8 (columns(A:G)) to your Count and to your final value to
> ensure it is the correct columns you are deleting
> --
>
> Regards
> Roger Govier
>
> "K" <kamranr1...@yahoo.co.uk> wrote in message
>
> news:9a375f02-e81c-4188-8581-(E-Mail Removed)...
>
>
>
>
>
> > Hi all, *I am trying to delete EntireColumn of Range("I9:BF9") where
> > cell value in that range is "X". *I tried doing it with below code but
> > I its not deleting all the columns. *I think I might need to put
> > something where it say "i" in line "If Cells(9, i).Value = "X" Then"
> > and "Cells(9, i).EntireColumn.Delete". But I cant work it out. Please
> > can any friend can help me on this

>
> > Code I am using************

>
> > Sub DelCol()
> > For i = Range("I9:BF9").Columns.Count To 1 Step -1
> > If Cells(9, i).Value = "X" Then
> > Cells(9, i).EntireColumn.Delete
> > End If
> > Next
> > End Sub

>
> > __________ Information from ESET Smart Security, version of virus
> > signature database 5641 (20101123) __________

>
> > The message was checked by ESET Smart Security.

>
> >http://www.eset.com

>
> __________ Information from ESET Smart Security, version of virus signature database 5641 (20101123) __________
>
> The message was checked by ESET Smart Security.
>
> http://www.eset.com- Hide quoted text -
>
> - Show quoted text -


thanks lot Roger
 
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
Delete entire row if column B shows - FJ Microsoft Excel Programming 6 8th Aug 2011 11:48 AM
CANNOT DELETE AN ENTIRE COLUMN ibeetb Microsoft Excel Misc 4 23rd Jun 2006 02:55 AM
Find Column heading and then Delete entire column Kobayashi Microsoft Excel Programming 4 17th Oct 2005 09:09 PM
Entire Column Delete =?Utf-8?B?ZXJtZWtv?= Microsoft Excel Programming 3 28th Apr 2005 02:17 PM
Delete Entire Row If Column C is Blank John Microsoft Excel Programming 5 19th Jul 2004 10:23 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:29 PM.