Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Conditionally clearing a cell

How would I clear the contents of a cell, if the cell to the left of it didn't contain a value greater than zero, then proceede the the cell below that one and repeat the same action and so forth until there were no more values to check. I'm stumped. Thanks for any help...

Don Rountree
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Conditionally clearing a cell

One way:

Public Sub ClearIfCellToLeftIsNotPositive()
Dim rCell As Range
Dim rClear As Range

For Each rCell In Range("B1:B" & _
Range("B" & Rows.Count).End(xlUp).Row)
With rCell
If .Offset(0, -1).Value <= 0 Then
If rClear Is Nothing Then
Set rClear = .Cells
Else
Set rClear = Union(rClear, .Cells)
End If
End If
End With
Next rCell
If Not rClear Is Nothing Then _
rClear.ClearContents
End Sub


In article ,
Don Rountree wrote:

How would I clear the contents of a cell, if the cell to the left of it
didn't contain a value greater than zero, then proceede the the cell below
that one and repeat the same action and so forth until there were no more
values to check. I'm stumped. Thanks for any help...

Don Rountree

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
Clearing a cell based on the value of another cell (INDIRECT data) without macros Cosi About this forum 0 June 15th 10 03:30 PM
Clearing cells without clearing formulas marsjune68 Excel Discussion (Misc queries) 2 April 10th 09 07:39 PM
Clearing a cell basil Excel Discussion (Misc queries) 4 April 30th 07 11:28 AM
clearing a cell ahegg New Users to Excel 2 April 1st 06 06:41 AM
clearing a cell genevieveg Excel Discussion (Misc queries) 1 January 11th 06 01:26 AM


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