Moving Contents Within Cells To Another Place

WillPeters

New Member
Joined
Oct 23, 2023
Messages
9
Office Version
  1. 2021
Platform
  1. Windows
Hello folks,

Based on the attached photo, at a click of a button, I would like to:
1. Copy the contents of A3 to C3
2. Paste in the next available, free cell. In this case, A12:C12
3. Clear contents of A3:C3

I'm struggling with getting the macro to paste at the bottom most, next available free cell.

Thanks in advance for your help!
 

Attachments

  • Screenshot 2024-03-06 150403.png
    Screenshot 2024-03-06 150403.png
    21.7 KB · Views: 20

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Assuming you have nothing else further down the page in column A, here is the code you can attach to your button:
VBA Code:
Sub MyCopyData()
    Range("A3:C3").Copy Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
    Range("A3:C3").ClearContents
End Sub
 
Upvote 0
If you do have other stuff outside of this further down the page in column A, this version should work:
VBA Code:
Sub MyCopyData()
    Dim nr As Long
    If Range("A10") = "" Then
        nr = 10
    Else
        nr = Range("A9").End(xlDown).Row + 1
    End If
    Range("A3:C3").Copy Range("A" & nr)
    Range("A3:C3").ClearContents
End Sub
 
Upvote 0
Solution
If you do have other stuff outside of this further down the page in column A, this version should work:
VBA Code:
Sub MyCopyData()
    Dim nr As Long
    If Range("A10") = "" Then
        nr = 10
    Else
        nr = Range("A9").End(xlDown).Row + 1
    End If
    Range("A3:C3").Copy Range("A" & nr)
    Range("A3:C3").ClearContents
End Sub
Appreciate you! That's exactly what I needed. Thank you
 
Upvote 0
You are welcome!

BTW, my "nr" variable stands for "next row".
So essentially, I am first calculating the next available row after row 9 and using that row variable in the paste section of the copy command.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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