Click to populate a cell elsewhere

VirtualHybrid

New Member
Joined
Mar 29, 2023
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello, I created a functional Google Sheets that I am trying to replicate in Excel.
If A1:A10 all have different values and I want B1 to populate based on the cell I clicked in A1:A10, how can I do that?
I'm assuming VB.

For example: If I click A5 I need B1 to reflect A5's value, If I click on A2 I need B1's value to update to that new value from A2.

Any input is appreciated!
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Click on a value in any cell in column A .
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Column <> 1 Then Exit Sub
    Range("B1") = Target
End Sub
 
Upvote 0
Solution
Welcome to the Board!

If A1:A10 all have different values and I want B1 to populate based on the cell I clicked in A1:A10, how can I do that?
If that really is accurate, you will need to tweak one line of mumps code, as his code will change B1 for any cell selected in column A, even ones below A10.
This will limit it to just A1:A10:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub
    Range("B1") = Target
End Sub
 
Upvote 0
Copy and paste this macro into the worksheet code module. Do the following: right click the tab name for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Click on a value in any cell in column A .
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Target.Column <> 1 Then Exit Sub
    Range("B1") = Target
End Sub
This worked perfectly, thank you!
 
Upvote 0
Welcome to the Board!


If that really is accurate, you will need to tweak one line of mumps code, as his code will change B1 for any cell selected in column A, even ones below A10.
This will limit it to just A1:A10:
VBA Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    If Intersect(Target, Range("A1:A10")) Is Nothing Then Exit Sub
    Range("B1") = Target
End Sub
Thank you! Mumps did the job but I was wondering how to change the column range so your post clarified that for me!
 
Upvote 0

Forum statistics

Threads
1,215,745
Messages
6,126,630
Members
449,323
Latest member
Smarti1

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