Add data from a cell when clicking on another cell

Darren_workforce

Board Regular
Joined
Oct 13, 2022
Messages
128
Office Version
  1. 365
Platform
  1. Windows
Hello,

I wondered if this could be done without using Form Controls. What I was hoping to do was generate a list of names in C:D. When clicking on one of the names, that name would be added into Column A (starting at A2) and then if A2 is occupied, clicking another name from C:D would then cause that name to populate in A3, and so on and so on. Can something like that be done?

Thank you in advance!!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Please try this:

Book2
ABCD
1NamesBlakeJanice
2JeffFrank
3HeraldMelissa
4JonseySarah
Sheet1


Put this code in the SHEET level area in Microsoft Excel Objects. My sheet name is Sheet1
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim i As Range
  Dim Cel As Range
  
  Set i = Intersect(Target, Range("C:D"))
  If Not i Is Nothing Then
    Cancel = True
    Set Cel = Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
    Cel.Value = i.Value
  End If
  
End Sub
 
Upvote 0
Please try this:

Book2
ABCD
1NamesBlakeJanice
2JeffFrank
3HeraldMelissa
4JonseySarah
Sheet1


Put this code in the SHEET level area in Microsoft Excel Objects. My sheet name is Sheet1
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
  Dim i As Range
  Dim Cel As Range
 
  Set i = Intersect(Target, Range("C:D"))
  If Not i Is Nothing Then
    Cancel = True
    Set Cel = Cells(Cells.Rows.Count, 1).End(xlUp).Offset(1, 0)
    Cel.Value = i.Value
  End If
 
End Sub
Added into the Worksheet, saved and exited. However, clicking on the cells with names does not carry the names over into A.
 
Upvote 0
The unfortunate part of VBA events is that just navigating through a cell using your keyboard arrows is the same as clicking a cell with a mouse.
 
Upvote 0
It worked for me so I have to ask. Did the code get pasted in the sheet you need this action?

1707146973366.png
 
Upvote 0
. . . And you have enabled macros?
Yes macros are enabled. I have another macro setup already. Sheet 1 (Sheet1) is the worksheet. I threw some of the department names into C and D. Periodically, when clicking names, the active cell does appear to be moving further and further down Column A but no names are populating. It's just activating the cell.
 
Upvote 0
Oh wow. So I had data further down in Column A ending at A43. I just happened to scroll down and all the names I clicked on appeared down there. So it is working...but not starting at the cell I anticipated it would.
 
Upvote 0

Forum statistics

Threads
1,215,102
Messages
6,123,097
Members
449,096
Latest member
provoking

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