Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Delete Columns based on a condition

I would like to be able to delete columns in the Active Spreadsheed based on
cells in a Range (B2:IV2), where any cells containing #Value! or Grand
Total would result in the column being deleted. I am using Excel 2000.

Joel


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default Delete Columns based on a condition

Joel,

You could do a macro:

Sub DeleteColumns()
Dim i As Integer

For i = 256 To 1 Step -1
If Cells(1, i).Text = "#VALUE!" Or _
Cells(1, i).Text = "Grand Total" Then
Cells(1, i).EntireColumn.Delete
End If
Next i
End Sub

HTH,
Bernie
MS Excel MVP

"Joel Mills" wrote in message
...
I would like to be able to delete columns in the Active Spreadsheed based

on
cells in a Range (B2:IV2), where any cells containing #Value! or Grand
Total would result in the column being deleted. I am using Excel 2000.

Joel




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Delete Columns based on a condition

Sub testerBBB()
Dim rng As Range, rng1 As Range
On Error Resume Next
Set rng = Range("B2:IV2").SpecialCells(xlFormulas, xlErrors)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireColumn.Delete
Do
Set rng1 = Range("B2:IV2").Find("Grand Total", _
Lookat:=xlPart)
If rng1 Is Nothing Then Exit Do
rng1.EntireColumn.Delete
Loop While True

End Sub

--
Regards,
Tom Ogilvy




"Joel Mills" wrote in message
...
I would like to be able to delete columns in the Active Spreadsheed based

on
cells in a Range (B2:IV2), where any cells containing #Value! or Grand
Total would result in the column being deleted. I am using Excel 2000.

Joel




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 79
Default Delete Columns based on a condition

Thanks Tom this work perfectly.

"Tom Ogilvy" wrote in message
...
Sub testerBBB()
Dim rng As Range, rng1 As Range
On Error Resume Next
Set rng = Range("B2:IV2").SpecialCells(xlFormulas, xlErrors)
On Error GoTo 0
If Not rng Is Nothing Then rng.EntireColumn.Delete
Do
Set rng1 = Range("B2:IV2").Find("Grand Total", _
Lookat:=xlPart)
If rng1 Is Nothing Then Exit Do
rng1.EntireColumn.Delete
Loop While True

End Sub

--
Regards,
Tom Ogilvy




"Joel Mills" wrote in message
...
I would like to be able to delete columns in the Active Spreadsheed

based
on
cells in a Range (B2:IV2), where any cells containing #Value! or Grand
Total would result in the column being deleted. I am using Excel 2000.

Joel






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
Delete Rows based on condition Vic Excel Discussion (Misc queries) 2 August 18th 09 08:54 PM
Delete row 1 based on condition in cell on row 2 McDuck Excel Worksheet Functions 0 July 30th 08 07:53 PM
Macro to delete rows based on a condition Darrilyn Excel Worksheet Functions 1 September 6th 07 12:12 AM
How to delete a data row based on a condition wmc New Users to Excel 4 April 18th 07 02:40 PM
Is there a way to delete a cell value based on a condition? Peanut Excel Discussion (Misc queries) 2 October 2nd 06 09:55 PM


All times are GMT +1. The time now is 02:03 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"