+ Reply to Thread
Results 1 to 4 of 4

MACRO TO COPY TO A RANGE

  1. #1
    asuncionw
    Guest

    MACRO TO COPY TO A RANGE

    I want a macro to copy A1:D1 up to the end of an empty cell, then do the same
    procedure for row 4 and so on and will stop only if the last row of the data
    in Col D=xxx (I dont know how to stop a macro and to loop in Excel, w/c I
    can do in Lotus). This would be an easy one for Macro experts and would
    appreciate your help since I'm new to Excel Macros.

    colA colB colC colD colE
    1 aa bb cc dd
    2
    3
    4 aa2 bb2 cc2 dd2
    5
    6
    7
    8 aa3 bb3 cc3 dd3
    9
    10 aa4 bb4 cc4 dd4 xxx


  2. #2
    exceluserforeman
    Guest

    RE: MACRO TO COPY TO A RANGE


    Not tested

    sub Printout_Ranges()
    dim i as integer
    i=0
    Range("A1").select
    set a=selection
    do until i=4
    a.offset(0,i).select
    a.end(xldown).select
    set z=selection
    if z.offset(0,i).value="" and a.offset(0,i).value="" then
    goto doop
    end if
    if z.offset(0,i).value="" then
    range(a.offset(0,i).printout=1
    else
    range(a.offset(0,i).address, z.address).printout=1

    end if

    Doop:
    i=i+1

    loop
    end sub


    "asuncionw" wrote:

    > I want a macro to copy A1:D1 up to the end of an empty cell, then do the same
    > procedure for row 4 and so on and will stop only if the last row of the data
    > in Col D=xxx (I dont know how to stop a macro and to loop in Excel, w/c I
    > can do in Lotus). This would be an easy one for Macro experts and would
    > appreciate your help since I'm new to Excel Macros.
    >
    > colA colB colC colD colE
    > 1 aa bb cc dd
    > 2
    > 3
    > 4 aa2 bb2 cc2 dd2
    > 5
    > 6
    > 7
    > 8 aa3 bb3 cc3 dd3
    > 9
    > 10 aa4 bb4 cc4 dd4 xxx
    >


  3. #3
    asuncionw
    Guest

    RE: MACRO TO COPY TO A RANGE

    Thanks, will try it and let you know.

    "exceluserforeman" wrote:

    >
    > Not tested
    >
    > sub Printout_Ranges()
    > dim i as integer
    > i=0
    > Range("A1").select
    > set a=selection
    > do until i=4
    > a.offset(0,i).select
    > a.end(xldown).select
    > set z=selection
    > if z.offset(0,i).value="" and a.offset(0,i).value="" then
    > goto doop
    > end if
    > if z.offset(0,i).value="" then
    > range(a.offset(0,i).printout=1
    > else
    > range(a.offset(0,i).address, z.address).printout=1
    >
    > end if
    >
    > Doop:
    > i=i+1
    >
    > loop
    > end sub
    >
    >
    > "asuncionw" wrote:
    >
    > > I want a macro to copy A1:D1 up to the end of an empty cell, then do the same
    > > procedure for row 4 and so on and will stop only if the last row of the data
    > > in Col D=xxx (I dont know how to stop a macro and to loop in Excel, w/c I
    > > can do in Lotus). This would be an easy one for Macro experts and would
    > > appreciate your help since I'm new to Excel Macros.
    > >
    > > colA colB colC colD colE
    > > 1 aa bb cc dd
    > > 2
    > > 3
    > > 4 aa2 bb2 cc2 dd2
    > > 5
    > > 6
    > > 7
    > > 8 aa3 bb3 cc3 dd3
    > > 9
    > > 10 aa4 bb4 cc4 dd4 xxx
    > >


  4. #4
    asuncionw
    Guest

    RE: MACRO TO COPY TO A RANGE

    Im getting syntax error on this line:
    > range(a.offset(0,i).printout=1



    "exceluserforeman" wrote:

    >
    > Not tested
    >
    > sub Printout_Ranges()
    > dim i as integer
    > i=0
    > Range("A1").select
    > set a=selection
    > do until i=4
    > a.offset(0,i).select
    > a.end(xldown).select
    > set z=selection
    > if z.offset(0,i).value="" and a.offset(0,i).value="" then
    > goto doop
    > end if
    > if z.offset(0,i).value="" then
    > range(a.offset(0,i).printout=1
    > else
    > range(a.offset(0,i).address, z.address).printout=1
    >
    > end if
    >
    > Doop:
    > i=i+1
    >
    > loop
    > end sub
    >
    >
    > "asuncionw" wrote:
    >
    > > I want a macro to copy A1:D1 up to the end of an empty cell, then do the same
    > > procedure for row 4 and so on and will stop only if the last row of the data
    > > in Col D=xxx (I dont know how to stop a macro and to loop in Excel, w/c I
    > > can do in Lotus). This would be an easy one for Macro experts and would
    > > appreciate your help since I'm new to Excel Macros.
    > >
    > > colA colB colC colD colE
    > > 1 aa bb cc dd
    > > 2
    > > 3
    > > 4 aa2 bb2 cc2 dd2
    > > 5
    > > 6
    > > 7
    > > 8 aa3 bb3 cc3 dd3
    > > 9
    > > 10 aa4 bb4 cc4 dd4 xxx
    > >


+ 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