Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
asuncionw
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
exceluserforeman
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
asuncionw
 
Posts: n/a
Default 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   Report Post  
Posted to microsoft.public.excel.misc
asuncionw
 
Posts: n/a
Default 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
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to find, copy, and paste until value change Valerie Excel Worksheet Functions 4 January 26th 06 04:10 AM
Macro to open workbook and copy and paste values in to orig workbo Dena X Excel Worksheet Functions 1 December 15th 05 11:13 PM
Resize Range - Macro Danny Excel Worksheet Functions 11 October 22nd 05 12:37 AM
Closing File Error jcliquidtension Excel Discussion (Misc queries) 4 October 20th 05 12:22 PM
Macro to copy cells Esrei Excel Discussion (Misc queries) 2 August 11th 05 11:31 AM


All times are GMT +1. The time now is 08:36 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"