Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Dennis
 
Posts: n/a
Default Delete Columns not Containing Certain Text

I would like to delete all rows with VBA that DO NOT contain the text TOTAL.
Struuggling some with it so far.

TIA, Dennis
================
  #2   Report Post  
Dennis
 
Posts: n/a
Default

Ooops.... I meant delete all columns, not rows...sorry.

Dennis
====================

In article ,
(Dennis) wrote:
I would like to delete all rows with VBA that DO NOT contain the text TOTAL.
Struuggling some with it so far.

TIA, Dennis
================

  #3   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Dennis,

Try:

Sub Tester()
Dim i As Integer

For i = ActiveSheet.UsedRange.Columns.Count To 1 Step -1
If Application.CountIf(Columns(i), "*Total*") = 0 Then
Columns(i).Delete
End If
Next i

End Sub

--

---
Regards,
Norman



"Dennis" wrote in message
m...
Ooops.... I meant delete all columns, not rows...sorry.

Dennis
====================

In article ,

(Dennis) wrote:
I would like to delete all rows with VBA that DO NOT contain the text
TOTAL.
Struuggling some with it so far.

TIA, Dennis
================



  #4   Report Post  
Dennis
 
Posts: n/a
Default

Works perfect, thanx Norm!!!!

Dennis
===================


In article , "Norman Jones"
wrote:
Hi Dennis,

Try:

Sub Tester()
Dim i As Integer

For i = ActiveSheet.UsedRange.Columns.Count To 1 Step -1
If Application.CountIf(Columns(i), "*Total*") = 0 Then
Columns(i).Delete
End If
Next i

End Sub

  #5   Report Post  
Norman Jones
 
Posts: n/a
Default

Hi Dennis,

In case the used range does not start in column A, better would be:

Sub Tester()
Dim i As Integer
Dim j As Integer

With ActiveSheet.UsedRange.Columns
j = .Column + .Count
End With

For i = j - 1 To 1 Step -1
If Application.CountIf(Columns(i), "*Total*") = 0 Then
Columns(i).Delete
End If
Next i

End Sub

---
Regards,
Norman



"Dennis" wrote in message
. com...
Works perfect, thanx Norm!!!!

Dennis
===================


In article , "Norman Jones"
wrote:
Hi Dennis,

Try:

Sub Tester()
Dim i As Integer

For i = ActiveSheet.UsedRange.Columns.Count To 1 Step -1
If Application.CountIf(Columns(i), "*Total*") = 0 Then
Columns(i).Delete
End If
Next i

End Sub



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
How can I delete ALL text boxes in Excel worksheets? Genesis Excel Discussion (Misc queries) 3 January 20th 05 03:11 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM
text from one column into multiple columns Jeff Brown Excel Discussion (Misc queries) 6 December 22nd 04 10:07 PM
Data Text to Columns RTP Excel Discussion (Misc queries) 4 December 10th 04 06:58 PM
splitting text to multiple columns maryj Excel Discussion (Misc queries) 5 December 1st 04 03:37 PM


All times are GMT +1. The time now is 06:54 PM.

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"