Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Delete Entire Column

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 376
Default Delete Entire Column

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" wrote in message
...
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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 557
Default Delete Entire Column

On Nov 23, 12:14*pm, "Roger Govier"
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" wrote in message

...





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
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
Need to delete last value in column but not delete entire row [email protected] Excel Programming 4 October 19th 06 05:26 PM
CANNOT DELETE AN ENTIRE COLUMN ibeetb Excel Discussion (Misc queries) 4 June 23rd 06 02:55 AM
Find Column heading and then Delete entire column Kobayashi[_58_] Excel Programming 4 October 17th 05 09:09 PM
Entire Column Delete ermeko Excel Programming 3 April 28th 05 02:17 PM
Delete Entire Row If Column C is Blank John Excel Programming 5 July 19th 04 10:23 PM


All times are GMT +1. The time now is 07:27 AM.

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"