Finding next blank cell error

ahowardmiller

New Member
Joined
Nov 22, 2017
Messages
3
Everything in my code works perfectly except the line marked below. Can someone help me figure out how to get it to find the next blank row and then paste. If I take the line of code out, it works but it replaces the previously saved data.
Code:
Private Sub CommandButton1_Click()
    With ActiveCell
    Range(Cells(.Row, "A"), Cells(.Row, "N")).Select
End With


    Selection.Copy
    Sheets("Completed").Select
[COLOR=#ff0000]    Cells(Rows.Count, "A").End(xlUp)(2).Select ** I get a range failed error 1004 here[/COLOR].
    ActiveSheet.Paste
    Sheets("Sheet1").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    
End Sub

Thank you for your time,
Aaron
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Aaron,

Try:

Code:
    nextRow = Range("A" & Rows.Count).End(xlUp).Row + 1
    Range("A" & nextRow).Select

This identifies the last row + 1, then selects it in the next line. Let me know if this is what you were looking for.

Bill
 
Last edited:
Upvote 0
Bill:
I've tried your code and similar code. I get the same range error where it gets to range. I'm stumped because I've used similar code in multiple projects. Thanks for your help.

Aaron
 
Upvote 0
Hi, welcome to the board.
As an alternatively, try
Code:
Private Sub CommandButton1_Click()
    With ActiveCell
    Range(Cells(.Row, "A"), Cells(.Row, "N")).Select
End With


    Selection.copy Sheets("Completed").Range("A" & Rows.Count).End(xlUp).Offset(1)
    Sheets("Sheet1").Select
    Application.CutCopyMode = False
    Selection.ClearContents
    
End Sub

Added
Having seen post#3 do you have sheet protection?
 
Last edited:
Upvote 0
Aaron,

I believe its a target error then:

Try:

Code:
nextRow = Sheets("Completed").Range("A" & Rows.Count).End(xlUp).Row + 1
Sheets("Completed").Range("A" & nextRow).Select

Let me know if it's any luck.

Bill
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,228
Messages
6,170,874
Members
452,363
Latest member
merico17

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