Click on a cell to copy&paste the cell value into the next empty row.

Ironhan

New Member
Joined
Jul 22, 2020
Messages
8
Office Version
  1. 2016
Platform
  1. Windows
Hi all,

Got two questions, hope you guys could help me out.

Q 1.

I got a range of cells [A1:C20] and I would like for any cell I click on in the range [A1:C20], to be copied and pasted in the empty cell of the range [D5:D20].
Eg. Click on cell[A1], the value gets copy&paste in [D5]. Click on cell[B13], the value gets copy&paste in [D6] and so on.

Q 2.

Similar to the one above, but if I click a specific cell(let's say it's [F1]) the whole range [D5:D20] gets emptied. (or the blank value gets copied and pasted, doesn't really matter)

Not sure if it'd help, but below is somewhat like what I'm trying to achieve except it only copies&pastes the value into one specific cell.

VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

If Target.Count = 1 And Target.Column = 4 Then
    Sheets("Sheet1").Range("F1").Value = Target.Value
End If

End Sub



Hopefully, this is an easy one, and appreciate your help!
 

Fluff

MrExcel MVP, Moderator
Joined
Jun 12, 2014
Messages
56,529
Office Version
  1. 365
Platform
  1. Windows
If the sheet is protected, then you need to unprotect it.
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
   If Target.CountLarge > 1 Then Exit Sub
   If Not Intersect(Target, Range("A1:C20")) Is Nothing Then
      Me.Unprotect "Password"
      On Error GoTo Oops
      Target.Copy Range("D5:D20").SpecialCells(xlBlanks)(1)
      On Error GoTo 0
   ElseIf Target.Address(0, 0) = "F1" Then
      Range("D5:D20").Clear
   End If
   Me.Protect "Password"
   Exit Sub
Oops:
   Me.Protect "Password"
   MsgBox "No space available in D5:D20"
End Sub
Change the Password to suit.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.

Watch MrExcel Video

Forum statistics

Threads
1,129,496
Messages
5,636,655
Members
416,934
Latest member
stoh18

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
Top