#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 10
Default delete based on

I have a list
where fields organisation and position
In the position the fields are either CC (chairman), CT (treasures) and CS
(secretary)

what if want is a macro to look up the list. and if the chairman field is
there, then delete row CT aND CS
and if CC is not there then keep either CT and if CT is not there then keep
CS
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 7,247
Default delete based on

Try some VBA code like the following:


Dim CCRng As Range
Dim CTRng As Range
Dim CSRng As Range

Set CCRng = Range("A:A").Find(what:="CC", lookat:=xlWhole,
LookIn:=xlValues)
If Not CCRng Is Nothing Then
Set CTRng = Range("A:A").Find(what:="CT", lookat:=xlWhole,
LookIn:=xlValues)
If Not CTRng Is Nothing Then
CTRng.EntireRow.Delete
End If
Set CSRng = Range("A:A").Find(what:="CS", lookat:=xlWhole,
LookIn:=xlValues)
If Not CSRng Is Nothing Then
CSRng.EntireRow.Delete
End If
End If



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"flow23" wrote in message
...
I have a list
where fields organisation and position
In the position the fields are either CC (chairman), CT
(treasures) and CS
(secretary)

what if want is a macro to look up the list. and if the
chairman field is
there, then delete row CT aND CS
and if CC is not there then keep either CT and if CT is not
there then keep
CS



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
Create formula that will pull a value based on text in diff cell? So Tru Geo Excel Discussion (Misc queries) 0 June 22nd 06 08:16 PM
Delete rows based on multiple criterias Benson Excel Discussion (Misc queries) 8 November 2nd 05 03:11 PM
Delete record(s) in other cells based on value of one cell. MPope Excel Discussion (Misc queries) 1 October 12th 05 06:57 PM
How to delete blank rows John Mansfield Excel Discussion (Misc queries) 3 April 27th 05 11:48 PM
Stubborn toolbars in Excel 007 Excel Discussion (Misc queries) 9 December 11th 04 02:02 PM


All times are GMT +1. The time now is 04:25 AM.

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"