extracting data in an array

B

bramnizzle

Hello fellow excel users...

I have a question on using vba to extract data from an array. Okay,
here's the scenario...

A B C
1 Task Deliver drawings 6/20/2007
2 General Note Did some things
3 General Note Finished some things
4 Task Order new drawings 6/21/2007
5 Task Finish drawings 6/22/2007
6 Phone Call Talked with Bill
7 Task Finish project 6/25/2007

A1:A7 are strings (obviously), as are B1:B7. There will not be any
dates in the rows that are NOT titled "Task". What I want to do is
have VBA extract the rows titled "Task" (including their subject and
date) and put them in a new column. Or something to that effect so
that when the code is run, what will be left is this...

Task Deliver drawings 6/20/2007
Task Order new drawings 6/21/2007
Taks Finish drawings 6/22/2007
Taks Finish project 6/25/2007

If it's possible, the rows with General Note and Phone Call can be
eliminated so that only rows with Task are left is fine. I didn't
know if sorting a new list or just eliminating rows would be easier.
Anyway, this is what I need and I don't know how to do that. Can
anyone help? Thanks.
 
G

Guest

Do you want VBA code?

Sub Eliminaterows()
Dim lastrow as Long, i as Long
lastrow = cells(rows.count,3).end(xlup).row
for i = lastrow to 1 step -1
if lcase(cells(i,1)) <> "task" or cells(i,3)="" then
rows(i).EntireRow.delete
end if
next
EndSub

Test this on a copy of your data to make sure it works.
 
B

bramnizzle

Wait! My bad!! It actually DID work!

At first there was an error in what you gave me. I thought it was
because you had "task" and not "Task". So I made it upper case. But
then I noticed you didn't have a space between EndSub. But I didn't
change Task back to task and later I noticed that you made everything
lowercase with LCase. It works perfect. This is EXACTLY what I
wanted. THANKS!!!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top