Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Clear cells in Column D if not = Auto

D have a spreadsheet and I want to clear all cells in Column B that is not
equal to Auto. Any help is certainly appreciated. Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Clear cells in Column D if not = Auto

Sub ClearAuto()
'Clear all cells with the value "Auto"
Dim i as Integer
Dim ItemCount as Integer
ItemCount = Application.WorksheetFunction.CountA(Columns("B"))
Range("B1").Select
For i = 1 to ItemCount
If ActiveCell.Value = "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub

"JOUIOUI" wrote:

D have a spreadsheet and I want to clear all cells in Column B that is not
equal to Auto. Any help is certainly appreciated. Thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Clear cells in Column D if not = Auto

Hi Paul, thanks for responding. I actually need to clear every cell that
does not include the text auto....I need to keep auto and clear any other
data in any of the other cells in that column. Can you help with that.
Thanks a bunch


"Paul Mathews" wrote:

Sub ClearAuto()
'Clear all cells with the value "Auto"
Dim i as Integer
Dim ItemCount as Integer
ItemCount = Application.WorksheetFunction.CountA(Columns("B"))
Range("B1").Select
For i = 1 to ItemCount
If ActiveCell.Value = "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub

"JOUIOUI" wrote:

D have a spreadsheet and I want to clear all cells in Column B that is not
equal to Auto. Any help is certainly appreciated. Thanks

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Clear cells in Column D if not = Auto

Whoops, sorry, I obviously did a dyslexic thing there. All you need to do is
change the conditional expression in the code I sent:

Change the item "If ActiveCell.Value = "Auto" to "If ActiveCell.Value <
"Auto"

That should get you the result you need. Sorry about that.

"JOUIOUI" wrote:

Hi Paul, thanks for responding. I actually need to clear every cell that
does not include the text auto....I need to keep auto and clear any other
data in any of the other cells in that column. Can you help with that.
Thanks a bunch


"Paul Mathews" wrote:

Sub ClearAuto()
'Clear all cells with the value "Auto"
Dim i as Integer
Dim ItemCount as Integer
ItemCount = Application.WorksheetFunction.CountA(Columns("B"))
Range("B1").Select
For i = 1 to ItemCount
If ActiveCell.Value = "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub

"JOUIOUI" wrote:

D have a spreadsheet and I want to clear all cells in Column B that is not
equal to Auto. Any help is certainly appreciated. Thanks

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 84
Default Clear cells in Column D if not = Auto

Hi again,

I forgot to mention that the code I sent presumes that you don't already
have any blank cells in your list of items. If you may possibly have blanks
in that list, you might be best off providing a range name for the data list.
Let's say you call the list "DataList". Then modify the code as follows:

Sub ClearNonAuto()
'Clear all cells with a value other than "Auto"
Dim i as Long
Dim ItemCount as Long
ItemCount = Range("DataList").Rows.Count
Range("DataList").Cells(1,1).Select
For i = 1 to ItemCount
If ActiveCell.Value < "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub


"JOUIOUI" wrote:

Hi Paul, thanks for responding. I actually need to clear every cell that
does not include the text auto....I need to keep auto and clear any other
data in any of the other cells in that column. Can you help with that.
Thanks a bunch


"Paul Mathews" wrote:

Sub ClearAuto()
'Clear all cells with the value "Auto"
Dim i as Integer
Dim ItemCount as Integer
ItemCount = Application.WorksheetFunction.CountA(Columns("B"))
Range("B1").Select
For i = 1 to ItemCount
If ActiveCell.Value = "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub

"JOUIOUI" wrote:

D have a spreadsheet and I want to clear all cells in Column B that is not
equal to Auto. Any help is certainly appreciated. Thanks



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 72
Default Clear cells in Column D if not = Auto

Great Paul, thanks so much. I'm really starting to understand this. Thanks
for the explanation, it helps a bunch!

"Paul Mathews" wrote:

Hi again,

I forgot to mention that the code I sent presumes that you don't already
have any blank cells in your list of items. If you may possibly have blanks
in that list, you might be best off providing a range name for the data list.
Let's say you call the list "DataList". Then modify the code as follows:

Sub ClearNonAuto()
'Clear all cells with a value other than "Auto"
Dim i as Long
Dim ItemCount as Long
ItemCount = Range("DataList").Rows.Count
Range("DataList").Cells(1,1).Select
For i = 1 to ItemCount
If ActiveCell.Value < "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub


"JOUIOUI" wrote:

Hi Paul, thanks for responding. I actually need to clear every cell that
does not include the text auto....I need to keep auto and clear any other
data in any of the other cells in that column. Can you help with that.
Thanks a bunch


"Paul Mathews" wrote:

Sub ClearAuto()
'Clear all cells with the value "Auto"
Dim i as Integer
Dim ItemCount as Integer
ItemCount = Application.WorksheetFunction.CountA(Columns("B"))
Range("B1").Select
For i = 1 to ItemCount
If ActiveCell.Value = "Auto" then ActiveCell.ClearContents
ActiveCell.Offset(1,0).Select
Next i
End Sub

"JOUIOUI" wrote:

D have a spreadsheet and I want to clear all cells in Column B that is not
equal to Auto. Any help is certainly appreciated. Thanks

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 to auto fill cells in column Carmen Bauer Excel Discussion (Misc queries) 1 August 1st 08 10:25 PM
Auto filling cells in a column Alex Excel Discussion (Misc queries) 7 October 16th 07 02:46 PM
How do I clear a column of data without clearing specific cells? EllenSwarts Excel Discussion (Misc queries) 2 April 5th 06 05:07 PM
Auto clear when qualification is met Paul987 Excel Discussion (Misc queries) 1 October 10th 05 01:53 PM
Auto Clear Cells PeteS Excel Programming 2 February 11th 04 06:16 AM


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