Location to paste, quick question

Desu Nota from Columbus

Well-known Member
Joined
Mar 17, 2011
Messages
556
I have the following code:
Code:
Dim i As Integer

For i = 16 To Range("L" & Rows.Count).End(xlUp).Row
    If Range("L" & i).Value = False Then
        Range("A" & i & ":" & "K" & i).Copy
            With Sheets("Sheet2")
                Range("A" & i).Paste
            End With
    End If
Next i
Inside the with statement, the range isn't accepted. I am copying values from 1 sheet, and then trying to have them paste in column A without copying over eachother.

I originally had (instead of the with statement):

Sheets("Sheet2").Paste

And all the values pasted to A1 so only 1 value was seen (because they pasted over one another). I've tried a plethora of different syntaxes but nothing I've tried thus far has worked.



How do you specify "paste to the first open cell in Column A, sheet2"?
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
I think you're making it too complicated. Try this:
Code:
Dim i As Integer
 
For i = 16 To Range("L" & Rows.Count).End(xlUp).Row
 
If Range("L" & i).Value = False Then Range("A" & i & ":" & "K" & i).Copy Sheets("Sheet2").Range("A" & i)
 
Next i
 
Upvote 0
Is their an implied TO in this statement?


If Range("L" & i).Value = False Then Range("A" & i & ":" & "K" & i).Copy TO Sheets("Sheet2").Range("A" & i)

Im just trying to understand why you don't have to give a direction after saying "copy".

Thanks for the help.
 
Upvote 0
There's an implied Destination. The full code would be:
If Range("L" & i).Value = False Then Range("A" & i & ":" & "K" & i).Copy Destination: Sheets("Sheet2").Range("A" & i)

Also, it's sometimes easier to refer to ranges using Cells, e.g
Code:
If Cells(i,12).Value = False Then Range(Cells(i,1),Cells(i,11)).Copy Sheets("Sheet2").Cells(i,1)
 
Upvote 0

Forum statistics

Threads
1,224,591
Messages
6,179,767
Members
452,940
Latest member
rootytrip

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