Link to home
Start Free TrialLog in
Avatar of jvera524
jvera524

asked on

Excel VBA Selecting Rows

Hello,

Starting at cell A2 I need to go row by row looking for todays date in column A. All columns that have todays date should be selected and copied to another workbook. After that I need to have several columns added and some counted.  Depending on the day there could be 100 records or none. Finally I need to have the file saved as a text, CSV, or XML file.  

Thanks for the help as always.  Please let me know of any questions.
Avatar of rspahitz
rspahitz
Flag of United States of America image

You don't need VBA to perform these task, although if you're doing them over and over, it may make sense.

For one thing, I would turn on filtering and only show today's date.  Then it's easy to select all and copy to another worksheet.
Then it's easy to go to that sheet and sum up the desired columns and count them then save the sheet as CSV.

I guess you could even record a macro with the steps and then you can run the macro every day.
  Should I show you the steps?
Avatar of jvera524
jvera524

ASKER

Yes over and over. If it were the same number of records each time then I understand what you stated above, but the number of records varies from day to day. This is why I thought a while or for loop would be needed to scan through column A looking for today's date.
ASKER CERTIFIED SOLUTION
Avatar of rspahitz
rspahitz
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also I need to change something from above.  Todays date is not important. What I need to grab is the new records added from day to day.  So if yesterday there were 1000 records and today there are 1020 records only the 20 new records should be grabbed.  I was thinking of having the number of records stored in a variable daily and then next day when the new records are added it gets the new total and based on the difference it grabs the new records which are always at the top of spreadsheet starting on row 2.
I suggest marking the ones that have been successfully processed then ignoring them

For example, add a new column (inserted into B?) and put an X to indicate that it's completed...this should be done when the macro completes.
The Private Sub SelectTodaysItems() seems to always assume the number of records is the same.  Am I correct in reading?  If so, it will not work if the number of records changes from day to day and some days there are none.

I understand the most recent suggestion. Thanks
It filters based on today's date, so if you are always running it today, it will always be the same unless new items are added with today's date.
I apologize for the confusion on my part.  I checked it today. There were new records some of which do not have todays date but I would still want to grab them.

So how do you know which have been processed and which don't ?  Without that info, this task cannot work effectively.