Click on a Cell and Contents of cell populate another cell in another worksheet

Msears

Board Regular
Joined
Apr 14, 2022
Messages
56
Office Version
  1. 365
  2. 2021
  3. 2019
Platform
  1. Windows
How can I make this code do this:
I have data in Col A and Col G, I want to click on any cell in A and it populate Col A and Col G into Col A and and D on worksheet 2?

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
If Not Intersect(Target, Range("A:A")) Is Nothing Then
If Target.Cells.Count > 1 Or IsEmpty(Target) Then Exit Sub
Cancel = True
Dim Lastrow As Long
Lastrow = Sheets("List").Cells(Rows.Count, "A").End(xlUp).Row + 1
Target.Copy Sheets("List").Cells(Lastrow, 1)
End If
End Sub
 
You're welcome & thanks for the feedback.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
One thing I would suggest:
Try reading the script and see if you understand the script.
Try making a new script similar to this but modify it a little and see what it does.
I sort of believe in the Proverb:
Give a Man a Fish, and You Feed Him for a Day. Teach a Man To Fish, and You Feed Him for a Lifetime.
You will really start to enjoy Excel more and more as you learn to write scripts. Take care
 
Upvote 0
Ok, how about
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
   If Target.Column = 1 Then
      Cancel = True
      If Target.Value = "" Then Exit Sub
      With Sheets("My Goals").Range("A" & Rows.Count).End(xlUp)
         .Offset(1).Value = Target.Value
         .Offset(1, 3).Value = Target.Offset(, 6).Value
      End With
   End If
End Sub
Thanks again for the help Fluff! My next quandary involves. Making this sheet auto sort by date (Oldest to Newest), domain (Alphabetical), goal (Smallest to Largest)?
 
Upvote 0
Thanks again for the help Fluff! My next quandary involves. Making this sheet auto sort by date (Oldest to Newest), domain (Alphabetical), goal (Smallest to Largest)?
Opps forgot to attach the pic!
 

Attachments

  • Capture.PNG
    Capture.PNG
    18.4 KB · Views: 3
Upvote 0
As this is a different question, it needs a new thread. Thanks
 
Upvote 0

Forum statistics

Threads
1,214,967
Messages
6,122,503
Members
449,090
Latest member
RandomExceller01

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