View Single Post
  #16   Report Post  
Posted to microsoft.public.excel.programming
Don Guillett[_4_] Don Guillett[_4_] is offline
external usenet poster
 
Posts: 2,337
Default Deleting Unneeded Records

Point well taken but the vbe should have make it red (or selected color)

--
Don Guillett
SalesAid Software

"Tom Ogilvy" wrote in message
...
Just an addendum
And if you had posted it like that originally, then it wouldn't have

looked
like it was on two separate lines (due to wordwrap).

--
Regards,
Tom Ogilvy

"Don Guillett" wrote in message
...
Had you put the if statement on one line then the end if would NOT have

been
necessary.
Or use a continuation line to break the line such as

Sub deleteifnopower()
For i = Cells(Rows.Count, "g").End(xlUp).Row To 1 Step -1
If UCase(Cells(i, "g")) < "POWER" And _
UCase(Cells(i, "h")) < "POWER" Then Rows(i).Delete
Next i
End Sub
--
Don Guillett
SalesAid Software

"Bill Foley" wrote in message
...
Had to end the "End If", but this does work. THANKS!

Sub deleteifnopower()
For i = Cells(Rows.Count, "g").End(xlUp).Row To 1 Step -1
If UCase(Cells(i, "g")) < "POWER" And UCase(Cells(i, "h")) < "POWER"

Then
Rows(i).Delete
End If
Next i
End Sub

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at: http://word.mvps.org/FAQs/General/index.htm

"Don Guillett" wrote in message
...
try

Sub deleteifnopower()
For i = Cells(Rows.Count, "g").End(xlUp).Row To 1 Step -1
If UCase(Cells(i, "g")) < "POWER" And UCase(Cells(i, "h")) <

"POWER"
Then
Rows(i).Delete
Next i
End Sub

--
Don Guillett
SalesAid Software

"Bill Foley" wrote in message
...
Another great idea! I was running into some syntax problems

working
with
the code Don provided (hence, UNTESTED). I'll try this method as

well
and
report back.

THANKS!

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at:

http://word.mvps.org/FAQs/General/index.htm

"Norman Jones" wrote in message
...
Hi Bill,

Add a helper column (say column M ) to your data and insert the
formula:

=OR(G2="Power",H2="Power")

in cell M2 and drag this down to the last row of data.

Then autofilter your data using TRUE as your criterion in column

M.

This should return all the data you want to delete.

---
Regards,
Norman


"Bill Foley" wrote in message
...
Hey Gang,

I am trying something new and need some assistance. I get a

new
workbook
each month with several hundred records on one worksheet. I

have
written
the simple macros to do the following:

1. Create a new WorkSheet
2. Copy all data from Sheet1 to Sheet2
3. Delete the unneeded columns
4. Autofit the remaining columns

The last thing I need to do is to delete all rows where

columns
"G"
or
"H"
do not include the word "Power". I can't simply autofilter

because
I
need
all records where "either" columns have "Power" in it.

Any code idea? I am sure it is simple, but my VBA use in

Excel
is
much
less
than my knowledge in PowerPoint or Word (and that is somewhat
limited)!
HA!

TIA!

--
Bill Foley, Microsoft MVP (PowerPoint)
Microsoft Office Specialist Master Instructor - XP
www.pttinc.com
Check out PPT FAQs at: http://www.rdpslides.com/pptfaq/
Check out Word FAQs at:

http://word.mvps.org/FAQs/General/index.htm