ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   extracting data in an array (https://www.excelbanter.com/excel-programming/391505-extracting-data-array.html)

[email protected]

extracting data in an array
 
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.


Tom Ogilvy

extracting data in an array
 
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.

--
Regards,
Tom Ogilvy


" wrote:

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.



[email protected]

extracting data in an array
 
This deleted all of the rows.



On Jun 18, 8:43 am, Tom Ogilvy
wrote:
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.

--
Regards,
Tom Ogilvy



[email protected]

extracting data in an array
 
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!!!!



All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com