Copy then paste special values to next empty row

levi58

New Member
Joined
Feb 9, 2011
Messages
5
:confused: I'm trying to create a macro that will copy the contents of c19:g19, and then paste special the values into the next empty row in this range, k5:036.
So far I can't figure out how to find the next empty row.
Any help would be greatly appreciated.

John
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
:confused: I'm trying to create a macro that will copy the contents of c19:g19, and then paste special the values into the next empty row in this range, k5:036.
So far I can't figure out how to find the next empty row.
Any help would be greatly appreciated.

John
Here's a UDF that you can use that will return the the next empty row (as a row number) in a range that you input as the argument.
Code:
Function LastRow(rng As Range)
Dim lRw As Long
lRw = 0
For Each rw In rng.Rows
    If WorksheetFunction.CountA(rw) = 0 Then
        lRw = rw.Row
        Exit For
    End If
Next rw
If lRw = 0 Then
    LastRow = CVErr(xlErrNA)
Else
    LastRow = lRw
End If
End Function
 
Last edited:
Upvote 0
This line is not clear to me.
next empty row in this range, k5:036.

I can't tell if your Range is K5 to O36. and if you are looking for the last empty cell in column K or column O.

If that is not a typo then 036 is not a valid cell.

Anyway, try this to identify your last empty row in column K. (change to suite)

Code:
LR = Range("K" & Rows.Count).End(xlUp).Offset(1).Row
 
Last edited:
Upvote 0
This line is not clear to me.


I can't tell if your Range is K5 to O36. and if you are looking for the last empty cell in column K or column O.

If that is not a typo then 036 is not a valid cell.

Anyway, try this to identify your last empty cell in column K. (change to suite)

Code:
LR = Range("K" & Rows.Count).End(xlUp).Offset(1).Row
If you want to ensure that ALL cells in the row(not just those in column K) are empty, you need the UDF I posted or something like it.
 
Upvote 0

Forum statistics

Threads
1,224,594
Messages
6,179,794
Members
452,943
Latest member
Newbie4296

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