+ Reply to Thread
Results 1 to 4 of 4

Offset (start after last row of previous procedure)-Merging macros

  1. #1
    Registered User
    Join Date
    10-04-2005
    Location
    NYC <--> Lagos
    Posts
    24

    Question Offset (start after last row of previous procedure)-Merging macros

    I am tryng to merge two macros here:
    I have two macros
    Each macro imports data from a text file, formats them appropriately (extracting data based on criteria) and placing them in designated columns in Sheet1

    The macro do absolutely the same thing, except the format of each (placement of data in each cell) in the text file is a little different.
    one macro (AggregateMetrics: ExtractDataX_Click) works with data prior to 3/2/05
    the other (SummaryMetrics: ExtractDataY_Click) works with data prior after 3/2/05.
    Reads text file and extracts specific data based on criteria.
    They both work perfectly.

    Except i am trying to merge the macro (instead of two) with IF statements to work based on criteria with just one text file that contains all the data.
    If date is >= 3/2/05...extract this from cells and place here
    else
    extract this from cells and place here

    Or perhaps If InStr(cell, "AGGREGATION METRICS:") > 0 Then ....
    and If InStr(cell, "SUMMARY METRICS:") > 0 Then

    Whichever is wiser!!


    I have attachd what i have so far and it's doesn't pick up the correct data, even thouh they both work perfectly independently. But tryng to combine things here with an IF statement is such a nightmare, and i have spent so muchtime on this already and i am getting no where.


    SO HERE IS WHAT I HAVE RESULTED TO: (correct me if this is a bad idea, I am open to suggestions please )

    I have a procedure where i call the two procedures [ExtractDataX_Click() and ExtractDataY_Click()] to extract data with each criteria, one after the other (see purple colored code).

    However there is one problem with my offset(...)
    I need the other procedure to pick up on the row where the other the other data left off. instead of overiding the data from the previous one.
    I am having trouble with the offset, i have shown the line in red

    Here's my code (excel also attached):
    Please Login or Register  to view this content.
    Thanks for taking the time to read my post.
    Please feel free to give me suggestions, ideas, anything.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    10-04-2005
    Location
    NYC <--> Lagos
    Posts
    24
    I have attached the sheet with my macro (zip file above)

    Macro is located in sheet2.
    I have imported the textfile inside the sheet.
    You may Click on the second button to run the code.

    Thank you.

  3. #3
    Patrick Molloy
    Guest

    Re: Offset (start after last row of previous procedure)-Merging ma

    The news group viewer that I use does not allow attachments, and I'd be
    surprised if anyone opened an attachment that could run live code.
    Usually better to display the offending code with as much description as
    possible.

    Sub GetValue(Thisdate as date)

    IF ThisDate >Cdate("3-feb-2005") Then
    ExtractDataY_Click
    else
    ExtractDataX_Click
    end if

    End Sub




    "Mslady" wrote:

    >
    > I have attached the sheet with my macro (zip file above)
    >
    > Macro is located in sheet2.
    > I have imported the textfile inside the sheet.
    > You may Click on the second button to run the code.
    >
    > Thank you.
    >
    >
    > --
    > Mslady
    > ------------------------------------------------------------------------
    > Mslady's Profile: http://www.excelforum.com/member.php...o&userid=27776
    > View this thread: http://www.excelforum.com/showthread...hreadid=478119
    >
    >


  4. #4
    Registered User
    Join Date
    10-04-2005
    Location
    NYC <--> Lagos
    Posts
    24
    Thanks patrick for taking the time to look.
    I attached the file just in case someone is able to download.

    I also pasted the code in my initial post: and i highlighted in red, where my problem is: I tried that you gave me, it doesn't work, because data from ExtractDataY overrides ExtractDataX . And i think the problem lies in my offset. I have highlight it in red in my code. Please take a look. Anybody..pleae

    Please Login or Register  to view this content.

+ 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