MACRO TO COPY TO A RANGE

A

asuncionw

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
 
E

exceluserforeman

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
 
A

asuncionw

Thanks, will try it and let you know.

exceluserforeman said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top