Need Help Please

reel03

New Member
Joined
Apr 25, 2017
Messages
6
Hi guys,
i need help.
i want to do copy-paste diffirent worksheet but with for next loop
for example:
Worksheets("Sheet1").Range("a1").copy = Worksheets("Sheet2").Range("a1").copy
Worksheets("Sheet1").Range("a2").copy = Worksheets("Sheet2").Range("a2").copy
etc...

Sheet1:
Sheet221f9.jpg


Sheet2
Sheet135fd.jpg




i have code but not working...
Sub for_loop()
Set wks = Worksheets("Sheet1")
On Error Resume Next

For i = 2 To wks.Range("A1" & Rows.Count).End(xlUp).Row
Worksheets("Sheet1").Range("A2").Value = Worksheets("Sheet2").Range("A2").Value
Next i


End Sub
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
You don't need a loop :

Code:
With Worksheets("Sheet1")
    .Range(.[A1], .Cells(Rows.Count, "A").End(xlUp)).Copy Sheets("Sheet2").[A1]
End With
 
Upvote 0
Code:
Sub for_loop()
Dim wks As Worksheet, n&
Set wks = Worksheets("Sheet1")
n = wks.Range("A1" & Rows.Count).End(xlUp).Row
For i = 1 To n
    Worksheets("Sheet2").Range("A" & i) = wks.Range("A" & i).Value
Next i
End Sub
 
Upvote 0
error code n& ?
Can u help me again


Code:
Sub for_loop()
Dim wks As Worksheet, n&
Set wks = Worksheets("Sheet1")
n = wks.Range("A1" & Rows.Count).End(xlUp).Row
For i = 1 To n
    Worksheets("Sheet2").Range("A" & i) = wks.Range("A" & i).Value
Next i
End Sub
 
Upvote 0
Code:
Sub for_loop()
Dim wks As Worksheet, n&
Set wks = Worksheets("Sheet1")
n = wks.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To n
    Worksheets("Sheet2").Range("A" & i) = wks.Range("A" & i).Value
Next i
End Sub
 
Upvote 0
thank you so much.
Well, how do just sheets2 A1 COPY, but with for next loop

for example .
Sheet1.a1.copy = Sheet2.a1.value
Sheet1.a2.copy = Sheet2.a1.value
Sheet1.a3.copy = Sheet2.a1.value



Code:
Sub for_loop()
Dim wks As Worksheet, n&
Set wks = Worksheets("Sheet1")
n = wks.Range("A" & Rows.Count).End(xlUp).Row
For i = 1 To n
    Worksheets("Sheet2").Range("A" & i) = wks.Range("A" & i).Value
Next i
End Sub
 
Upvote 0
thank you so much.
Well, how do just sheets2 A1 COPY, but with for next loop

for example .
Sheet1.a1.copy = Sheet2.a1.value
Sheet1.a2.copy = Sheet2.a1.value
Sheet1.a3.copy = Sheet2.a1.value

The code I posted copies from Sheet1 and pastes to Sheet2.
If you want to do the other way around, just switch the sheet refs in the code.
( wks.Range("A" & i) = Worksheets("Sheet2").Range("A" & i).Value )
If you want something different, post again since I don't understand.
 
Last edited:
Upvote 0
thank you answer. i fixed problem.
Best regards.


The code I posted copies from Sheet1 and pastes to Sheet2.
If you want to do the other way around, just switch the sheet refs in the code.
( wks.Range("A" & i) = Worksheets("Sheet2").Range("A" & i).Value )
If you want something different, post again since I don't understand.
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,159
Members
453,021
Latest member
Justyna P

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