+ Reply to Thread
Results 1 to 3 of 3

Delete rows in multiple files using criteria in a seperate workbook

  1. #1
    Registered User
    Join Date
    09-11-2012
    Location
    Polokwane, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    2

    Delete rows in multiple files using criteria in a seperate workbook

    Hi everyone,

    I'm new to this forum and to VBA, so your help would be greatly appreciated!

    First-off, I'm using Windows XP and Excel 2003 SP3.

    The setup: A software application I regularly use produces csv data files (in this case approx 300 files). These I have converted to xls format using a separate macro. The files are in one folder and named as follows eg

    G1 18800.xls
    G1 18802.xls
    G2 18975.xls
    G3 19881.xls
    G3 19990.xls
    G5 19990.xls
    etc

    The files contain the following data:

    DATE TIME VALUE STEPS EXCL ACCEL
    01-Oct-03 08:00 0 0 FALSE 0
    01-Oct-03 08:01 0 0 FALSE 0
    01-Oct-03 08:02 0 0 FALSE 0
    01-Oct-03 08:03 0 0 FALSE 0
    01-Oct-03 08:04 757 20 FALSE 0.18
    01-Oct-03 08:05 1714 32 FALSE 0.44
    01-Oct-03 08:06 1524 32 FALSE 0.39
    01-Oct-03 08:07 1665 45 FALSE 0.47
    01-Oct-03 08:08 1644 42 FALSE 0.46
    01-Oct-03 08:09 263 8 FALSE 0.06
    etc


    I then created a macro using code I sourced from the internet, and included some addtional commands (filename, copy/paste). See below. This macro opens the all the xls data files in the folder and copies the relevant data to an analysis workbook [Analysis sheet, Results sheet, Master sheet] ie the data is copied from the data file and pasted into the Analysis worksheet. Then the results are copied from the Results sheet to the Master sheet. So far everything works.

    Please Login or Register  to view this content.
    My problem is this: I'm stumped at how to delete rows from the xls data files before running the analysis workbook and macro. In other words, after converting the csv files to xls format I need to clean the xls data files.

    I have a separate xls file with criteria data in two columns:

    FileName Date
    G1 18800 06-Oct-03
    G1 18801 02-Oct-03
    G1 18801 03-Oct-03
    G1 18801 05-Oct-03
    G2 18795 14-Oct-03
    G2 18795 15-Oct-03
    G2 18795 16-Oct-03
    G2 18795 17-Oct-03
    etc


    The rows in a particular data file, with dates that are not present in the Criteria workbook must be deleted. This to be done for every data file in the folder. Also, I need to
    exclude rows for specific time periods eg 12H00AM - 04H00AM from all the files irrespective of date. I'd be most appreciative of the code needed [should a separate macro be run or can code be placed within the present macro?]. I've tried looking for something similar on the internet but have not been able to find something that I could adapt with my current skill level.

    Your assistance would save an enormous amount of time cleaning manually!

    Thanks!
    Ian

  2. #2
    Forum Contributor arlu1201's Avatar
    Join Date
    09-09-2011
    Location
    Bangalore, India
    MS-Off Ver
    Excel 2003 & 2007
    Posts
    19,166

    Re: Delete rows in multiple files using criteria in a seperate workbook

    Why dont you attach the following? -

    1. A sample of a few of your .xls files (remove sensitive data)
    2. A sample of your criteria file.

    To Attach a File:

    1. Click on Go Advanced
    2. In the frame Attach Files you will see the button Manage Attachments
    3. Click the button.
    4. A new window will open titled Manage Attachments - Excel Forum.
    5. Click the Browse... button to locate your file for uploading.
    6. This will open a new window File Upload.
    7. Once you have located the file to upload click the Open button. This window will close.
    8. You are now back in the Manage Attachments - Excel Forum window.
    9. Click the Upload button and wait until the file has uploaded.
    10. Close the window and then click Submit.
    If I have helped, Don't forget to add to my reputation (click on the star below the post)
    Don't forget to mark threads as "Solved" (Thread Tools->Mark thread as Solved)
    Use code tags when posting your VBA code: [code] Your code here [/code]

  3. #3
    Registered User
    Join Date
    09-11-2012
    Location
    Polokwane, South Africa
    MS-Off Ver
    Excel 2003
    Posts
    2

    Re: Delete rows in multiple files using criteria in a seperate workbook

    Hi Arlette,

    I've attached a criteria file as well as a zip file with 5 data files.

    Thanks so much for looking at this!

    Kind regards,
    Ian
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1