+ Reply to Thread
Results 1 to 6 of 6

Triple Loop-Parsing data to new file

  1. #1
    Registered User
    Join Date
    05-09-2012
    Location
    Calgary,Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Triple Loop-Parsing data to new file

    Hi, I'm fairly new to Excel VBA, this is suppose to be pretty simple, please help =)

    So I need to extract raw data files onto another excel file, but I need to use loops to search for the data file needed. Here's the basic idea of what I need to do:

    XREF_MODEL_SCHEMA.xls
    'so here I need to do a loop to search for the "yes" under the "compare" tab in the sheet(shunt)
    Row=Model_1st_Data_Row
    'I am suppose to do a loop to identify the rows with "yes" under the compare, until the the cell is empty
    Do Until is empty (cells (row,?))
    compare = cells (row, column_SCHEMA_COMPARE)
    'define COL_SCHEMA_COMPARE, so from the file, the compare tab is in column 1, but since it might change later, I don't want to hard code it, so I need to define it to column 1 for now, later on I only need to change the define if i need to make changes.
    if (compare="yes") 'in this case the row with MODSW and row with BINIT are "yes"
    'so here I go into the next attached file, under switched_shunt sheet, I need to search the columns until it finds "MODSW" and "BINIT" and remeber the corresponding number on the left of it, here it should always be row#-1,the numbers will be used later. Remember these 2 IDs are "yes" from the previous file. (MODSW and BINIT are the PSSE IDs)
    PSSE_RAW_FORMAT.xlsx
    then PSSE_ID= cells ( ROW,COL_SCHEMA_PSSE)
    'the following is the file I need to parse the desired data to, as you can see, I need to copy the data into the sheet(shunt)
    PSSE_MODEL2.xlsx
    'I'm suppose to define this file as the following line suggests, but I'm not sure why...
    Define PSSE Model
    'next I need to go into the the attachment file PSSE_ RAW_FORMAT, (I will link again)[PSSE_RAW_FORMAT.xlsx
    'and write the PSSE_ID (which is MODSW and BINIT in this case) onto my new file PSSE_model2PSSE_MODEL2.xlsxas headings
    'I need to write the IDs as headings in row 1, since cell(1,1) is taken, I need to write them onto the next empty space in row 1, so in this case, MODSW would be in cell(1,2), and BINIT would be in cell(1,3), again I don't want to hard code them into those particular cells
    Write PSSE_ID as heading onto PSSE_MODEL2
    'now I need to go into the raw data file which is provided below, and filter to the data I want, which is the shunt data, and it starts after a record that starts with "0/" and contains the substring "BEGIN SWITCHED SHUNT DATA", uptil a recod that starts with "0/" and contains the substring "END OF SWITCHED SHUNT DATA". In this particular file, they are found in row 10193 and 10342 (for your convinience), although these 2 numbers will change as the parameters won't stay the same, so I loop that sorts through all the data and records the rows of datas inbetween these 2 substring. And only the columns that are determined by the corresponding numbers of MODSW and BINIT from the PSSE_FORMAT are recorded. (I highlighted that step as red, so it's easier for you to remember where we found the columns. So in this case, the columns we need are 2 and 8.
    And last we just paste those data under the corresponding tab in PSSE_MODEL2

    PSSE_RAW.xlsx

    I know it's a lot of info, and some might be confusing, I tried my best to explain it, if you have any uncertainties, let me know, and I will do my best to explain.

    Thank you
    Attached Files Attached Files
    Last edited by Hallet; 05-10-2012 at 03:55 PM.

  2. #2
    Registered User
    Join Date
    05-09-2012
    Location
    Calgary,Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Triple Loop-Parsing data to new file

    ignore the attached file
    Workbook 1.xlsx

  3. #3
    Registered User
    Join Date
    05-09-2012
    Location
    Calgary,Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Triple Loop-Parsing data to new file

    the ? in the Do Until IsEmpty is COL_SCHEMA_COMPARE, which is 1

  4. #4
    Registered User
    Join Date
    05-09-2012
    Location
    Calgary,Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Triple Loop-Parsing data to new file

    bump
    really need help with this as it is due soon

  5. #5
    Registered User
    Join Date
    05-09-2012
    Location
    Calgary,Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Triple Loop-Parsing data to new file

    and any ideas for reducing the run time is welcome as well

  6. #6
    Registered User
    Join Date
    05-09-2012
    Location
    Calgary,Canada
    MS-Off Ver
    Excel 2010
    Posts
    50

    Re: Triple Loop-Parsing data to new file

    still need some help with this

+ 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