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!!
 
ok Re-tested after clearing all the names. Clicked on 1 name and it populated in A44, below some of the Row headers I have setup. I moved the data from A into L so that A was completely empty save for the A1 header. Tried and it works as designed. Thank you for sticking with me and helping out on that!!
 
Upvote 0

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Yeah, the code I gave you starts at the last row and goes up to the last non-empty cell in column A. Do you need that changed?
 
Upvote 0
Yeah, the code I gave you starts at the last row and goes up to the last non-empty cell in column A. Do you need that changed?
At most, there may be 20 names that would need to be added into Column A on any given day. So having the range a2:a35 would be more than sufficient. Can the range be restricted like that and still work?
 
Upvote 0
This code looks from the top down for the next empty cell

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(2, 1)
    Do Until Cel.Value = ""
      Set Cel = Cel.Offset(1, 0)
    Loop
    Cel.Value = i.Value
  End If
 
End Sub
 
Upvote 0
Solution
This code looks from the top down for the next empty cell

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(2, 1)
    Do Until Cel.Value = ""
      Set Cel = Cel.Offset(1, 0)
    Loop
    Cel.Value = i.Value
  End If
 
End Sub
Yeah that's EXACTLY what I was hoping for!! Thank you @Jeffrey Mahoney
 
Upvote 0

Forum statistics

Threads
1,215,092
Messages
6,123,063
Members
449,090
Latest member
fragment

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