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
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
I helped you once before on a similar post;
You said sheet to copy to was named "List"
And you only wanted values posted.
So try this:
Change sheet name to your needs
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
'Modified  4/14/2022  1:11:37 PM  EDT
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
Sheets("List").Cells(Lastrow, 1).Value = Target.Value
Sheets("List").Cells(Lastrow, 4).Value = Target.Offset(, 6).Value
End If
End Sub
 
Upvote 0
Hi & welcome to MrExcel.
What is the name of the sheet the data should be copied?
Also what row should it be copied to?
 
Upvote 0
Hi & welcome to MrExcel.
What is the name of the sheet the data should be copied?
Also what row should it be copied to?
Hello. This is my first time, I just posted code from another thread that works for me, but I wanted to change it up somewhat. The target sheet is called “Master Goals” and it has data in Col A and data in Col G. I want to click any cell in A and when I do that I want it to take the corresponding cell in Col G, and populate in a sheet called “My Goals”, and put A and G’s data in Col A and B on the My Goals sheet? I hope that makes sense?
 
Upvote 0
Do you want it to go to a specific row, or to the next empty row?
 
Upvote 0
I got involved here this time because I got a notification saying you had a question about one of my posting on a similar request.
But now that Fluff is helping you I will move on. 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
 
Upvote 0
Solution

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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