Paste selection into next available row

PCTech

Board Regular
Joined
Mar 24, 2005
Messages
215
I'm trying to copy a range of a row to another sheet if column AL contains an O. It errors out on Selection.End(xlDown).Offset(1, 0).Select.
Will someone please help me with this?

Code:
Sub CopyOdds()
Sheets("Cab. Order").Select
For i = 16 To 300 Step 1
    If Range("AL" & i) = "O" Then
        Range("c" & i & ":" & "K" & i).Select
    Selection.Copy
    Sheets("Odds").Select
    Range("C2").Select
    Selection.End(xlDown).Offset(1, 0).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
    :=False, Transpose:=False
End If
Next i
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
This is how I got it to work. I don't understand why, but this works

Code:
Sub CopyOdds()
Sheets("Cab. Order").Select
For i = 300 To 52 Step 1
    If Range("AL" & i) = "O" Then
        Range("c" & i & ":" & "K" & i).Select
    Selection.Copy
        Sheets("Odds").Range("C" & Rows.Count).End(xlUp).Offset(1, 0). _
        PasteSpecial xlValues
End If
Next i
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,529
Messages
6,125,345
Members
449,220
Latest member
Edwin_SVRZ

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