How to stop this from looping

crazybuckeyeguy

New Member
Joined
Apr 15, 2017
Messages
49
when I run this command I assume its trying to past every cell into B3. How do I just make it copy and past from row 12 to the last row then paste?

Sub Copydata()
Sheets("Data").Activate
Dim lr As Long
lr = Range("A" & Rows.Count).End(xlUp).Row
For i = lr To 2 Step -1
Range("A12:M" & i).Select
Selection.Copy
Sheets("Check In").Select
Range("B3").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False


Next i
End Sub
 

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
You don’t need loop to the job.
Assuming sheet Data is active sheet, try this:


Please use Code Tags when posting a code.
Code:
[B][COLOR=Royalblue]Sub[/COLOR][/B] Copydata[B]()[/B]
[B][COLOR=Royalblue]Dim[/COLOR][/B] lr [B][COLOR=Royalblue]As[/COLOR][/B] [B][COLOR=Royalblue]Long[/COLOR][/B][B],[/B] r [B][COLOR=Royalblue]As[/COLOR][/B] Range
   
   [B][COLOR=Royalblue]Set[/COLOR][/B] r [B]=[/B] Range[B]([/B][B][COLOR=brown]"A12:M"[/COLOR][/B] [B]&[/B] Cells[B]([/B]Rows.count[B],[/B] [B][COLOR=brown]"A"[/COLOR][/B][B]).[/B][B][COLOR=Royalblue]End[/COLOR][/B][B]([/B]xlUp[B]).[/B]row[B])[/B]
   Sheets[B]([/B][B][COLOR=brown]"Check In"[/COLOR][/B][B]).[/B]Range[B]([/B][B][COLOR=brown]"B3"[/COLOR][/B][B]).[/B]Resize[B]([/B]r.Rows.count[B],[/B] r.Columns.count[B]).[/B]Value [B]=[/B] r.Value
 
[B][COLOR=Royalblue]End[/COLOR][/B] [B][COLOR=Royalblue]Sub[/COLOR][/B]

 
Upvote 0

Forum statistics

Threads
1,223,897
Messages
6,175,271
Members
452,628
Latest member
dd2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top