Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Cell Content Removal

I was wondering if someone could help me with a macro where it would remove
cell contents if certain criteria is not met.
Weekly i create a new file to be distributed that I need to clean up up cell
contents that does not meet specific criteria.
The criteria I need to meet is the following, column name listed first, than
criteria, for all others I will need the cell contents removed for the column
name listed below.

Column Name and Criteria where cell contents are needed for three columns
within worksheet:
Year = 2008 or greater
Defect = "Yes"
Human Error = "Yes or "No"
Status = "Closed", or" Closed - No Action" or "Contionous"

If this criteria is not met above than remove cell contents in the following
columns: "Project", "Details", and "Cost"
I am thinking I need some type of dowhile loop, but not real fluent on VBA.
Any help would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Cell Content Removal

You didn't specify the column so I made the code generic. Change the column
letters as required.

Sub RemoveData()

YearCol = "A"
DefectCol = "B"
HumanErrCol = "C"
StatusCol = "D"
ProjectCol = "E"
DetailsCol = "F"
CostCol = "G"

RowCount = 1
Do While Range("A" & RowCount) < ""
MyYear = Year(Range(YearCol & RowCount))
Defect = Range(DefectCol & RowCount)
HumanErr = Range(HumanErrCol & RowCount)
Status = Range(StatusCol & RowCount)
If (MyYear < 2008) Or _
(Defect < "YES") Or _
(HumanErr < "YES" And HumanErr < "No") Or _
(Status < "Closed" And Status < "Closed - No Action" And _
Status < "Contionous") Then


Range(ProjectCol & RowCount).ClearContents
Range(DetailsCol & RowCount).ClearContents
Range(CostCol & RowCount).ClearContents
End If
RowCount = RowCount + 1
Loop


End Sub


"Jen_T" wrote:

I was wondering if someone could help me with a macro where it would remove
cell contents if certain criteria is not met.
Weekly i create a new file to be distributed that I need to clean up up cell
contents that does not meet specific criteria.
The criteria I need to meet is the following, column name listed first, than
criteria, for all others I will need the cell contents removed for the column
name listed below.

Column Name and Criteria where cell contents are needed for three columns
within worksheet:
Year = 2008 or greater
Defect = "Yes"
Human Error = "Yes or "No"
Status = "Closed", or" Closed - No Action" or "Contionous"

If this criteria is not met above than remove cell contents in the following
columns: "Project", "Details", and "Cost"
I am thinking I need some type of dowhile loop, but not real fluent on VBA.
Any help would be greatly appreciated.

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
Cell content removal Jen_T Excel Programming 11 February 11th 09 07:10 PM
Cell Content Removal Jen_T Excel Programming 0 February 9th 09 01:36 PM
Removal of cell contents Jen_T Excel Programming 0 February 9th 09 01:18 PM
removal of first digit on left in cell Penny Excel Programming 3 January 20th 09 11:26 PM
Removal of cell objects M Excel Discussion (Misc queries) 5 November 7th 08 04:09 PM


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