#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Loop Copy

I have a sheet formatted as follows:
A B C
HEADER ROW
HEADER ROW
101 1-1-10 Address
102 1-3-10 Address
103 2-8-10 Address

I need to create some code to do the following:

Create a new sheet named "Labels"
Copy original sheet A3 to new sheet A1
Merge Cells A1:B6
Copy original sheet B3 to new sheet C1
Copy original sheet C3 to new sheet D1
Add page Break
Do the same as above for the next row on the original sheet and so on. Could
be unlimited number of rows on original sheet.

Any help is greatly appreciated. Thanks

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Loop Copy

Try this:

==========
Sub MakeLabels()
Dim LR As Long, i As Long, NR As Long
Dim ws As Worksheet
LR = Range("A" & Rows.Count).End(xlUp).Row
NR = 1
Set ws = Sheets("Labels")

For i = 3 To LR
ws.Range("A" & NR) = Cells(i, "A")
ws.Range("C" & NR) = Cells(i, "B")
ws.Range("D" & NR) = Cells(i, "C")
ws.Range("A" & NR, "B" & NR + 5).MergeCells = True
NR = NR + 6
Next i

End Sub
=============

--
"Actually, I *am* a rocket scientist." -- JB
(www.MadRocketScientist.com)

Your feedback is appreciated, click YES if this post helped you.


"brownti via OfficeKB.com" wrote:

I have a sheet formatted as follows:
A B C
HEADER ROW
HEADER ROW
101 1-1-10 Address
102 1-3-10 Address
103 2-8-10 Address

I need to create some code to do the following:

Create a new sheet named "Labels"
Copy original sheet A3 to new sheet A1
Merge Cells A1:B6
Copy original sheet B3 to new sheet C1
Copy original sheet C3 to new sheet D1
Add page Break
Do the same as above for the next row on the original sheet and so on. Could
be unlimited number of rows on original sheet.

Any help is greatly appreciated. Thanks

--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default Loop Copy

works perfect. Thank you!

JBeaucaire wrote:
Try this:

==========
Sub MakeLabels()
Dim LR As Long, i As Long, NR As Long
Dim ws As Worksheet
LR = Range("A" & Rows.Count).End(xlUp).Row
NR = 1
Set ws = Sheets("Labels")

For i = 3 To LR
ws.Range("A" & NR) = Cells(i, "A")
ws.Range("C" & NR) = Cells(i, "B")
ws.Range("D" & NR) = Cells(i, "C")
ws.Range("A" & NR, "B" & NR + 5).MergeCells = True
NR = NR + 6
Next i

End Sub
=============

I have a sheet formatted as follows:
A B C

[quoted text clipped - 16 lines]

Any help is greatly appreciated. Thanks


--
Message posted via OfficeKB.com
http://www.officekb.com/Uwe/Forums.a...mming/200910/1

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
For next loop and copy and pasting VBA [email protected] Excel Programming 5 June 29th 07 08:03 PM
Copy and Paste using a loop bestie via OfficeKB.com Excel Programming 0 August 3rd 06 08:57 AM
Copy range from 1 wks to another w/loop Dan Excel Programming 5 March 5th 05 01:52 PM
Need Help With A Loop To Copy vsingler Excel Programming 2 August 17th 04 08:31 PM
search & copy with loop Don Guillett[_4_] Excel Programming 0 July 24th 03 02:55 PM


All times are GMT +1. The time now is 04:06 PM.

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"