+ Reply to Thread
Results 1 to 4 of 4

Macro to extract data

  1. #1
    Registered User
    Join Date
    02-12-2006
    Posts
    2

    Macro to extract data

    I'm dealing with a weekly list that is broken into various segments, separated by a header line. I'm trying to build a macro that will copy all the data in say the first segment to another sheet for sorting, etc. .
    My previous Lotus experience (say 6 years ago) would let me do a "end", "dn arrow" to get to the next header line(an open cell in column G), then copy back up to capture my data. When I do that with excel in captures the cell address at the end of the "end"+"dn arrow" sequence and stores that cell address as part of the macro (eg. G51). If I use the macro on a new list where the next header line is at say row 45, the macro will still go to line 51 and copy from that point.
    Maybe my "end , down" is the wrong approach. Any suggestions?? Thanks
    Last edited by Bill A; 02-14-2006 at 09:35 PM.

  2. #2
    Otto Moehrbach
    Guest

    Re: Macro to extract data

    Bill
    If you use End - Down on a continuous column of data (header rows are
    filled) Excel will go to the last entry in the column. Maybe I'm missing
    what you are saying.
    If your data is continuous and you want to copy (or whatever) just a
    portion of it with VBA, you will have to write the code so that Excel can
    find the extremities of what you want copied. For instance, if you want to
    copy from here to the next header row, but not the header row itself, you
    have to use a search routine to find the next header row. For instance, say
    the next header in a column is "Header1", you would write code to search for
    "Header1" and to start the search after some cell of your choosing. That
    way, Excel will find only the next header even if the header text is
    repeated in the data. Then you can write the code to copy just what you
    want.
    Not knowing any more about your data layout than what you said, I can't
    give you any more. Post back with more details about your data if you need
    more. HTH Otto
    "Bill A" <[email protected]> wrote in
    message news:[email protected]...
    >
    > I'm dealing with a weekly list that is broken into various segments,
    > separated by a header line. I'm trying to build a macro that will copy
    > all the data in say the first segment to another sheet for sorting, etc.
    > .
    > My previous Lotus experience (say 6 years ago) would let me do a
    > "end", "dn arrow" to get to the next header line, then copy back up to
    > capture my data. When I do that with excel in captures the cell
    > address at the end of the "end"+"dn arrow" sequence and stores that
    > cell address as part of the macro (eg. G51). If I use the macro on a
    > new list where the next header line is at say row 45, the macro will
    > still go to line 51 and copy from that point.
    > Maybe my "end , down" is the wrong approach. Any suggestions??
    > Thanks
    >
    >
    > --
    > Bill A
    > ------------------------------------------------------------------------
    > Bill A's Profile:
    > http://www.excelforum.com/member.php...o&userid=31480
    > View this thread: http://www.excelforum.com/showthread...hreadid=511577
    >




  3. #3
    Registered User
    Join Date
    02-12-2006
    Posts
    2
    Thanks for the response. I wasn't clear about my data layout. My headers that separate segments only occupy 3 cells horizontal so I went to column "D" in the data & did "End-Dn" so it would stop when it came to the open cell in the header row. If the number of rows of data in the first segment changed ,the macro would still go to the original stopping point in column D. I hope that is more clear.
    Meanwhile I'll try to incorperate the search routine you suggested. Thanks a lot.

  4. #4
    Otto Moehrbach
    Guest

    Re: Macro to extract data

    Bill
    If you wish, send me a small file direct via email showing your data
    layout and an explanation of what you want to happen (copy what to where,
    followed by copying another what to another where, etc.). I'll work up some
    code for you. My email address is [email protected]. Remove the "nop"
    from this address. HTH Otto
    "Bill A" <[email protected]> wrote in
    message news:[email protected]...
    >
    > Thanks for the response. I wasn't clear about my data layout. My headers
    > that separate segments only occupy 3 cells horizontal so I went to
    > column "D" in the data & did "End-Dn" so it would stop when it came to
    > the open cell in the header row. If the number of rows of data in the
    > first segment changed ,the macro would still go to the original
    > stopping point in column D. I hope that is more clear.
    > Meanwhile I'll try to incorperate the search routine you suggested.
    > Thanks a lot.
    >
    >
    > --
    > Bill A
    > ------------------------------------------------------------------------
    > Bill A's Profile:
    > http://www.excelforum.com/member.php...o&userid=31480
    > View this thread: http://www.excelforum.com/showthread...hreadid=511577
    >




+ 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