Help with selected a name in a range

Peter083

Board Regular
Joined
Feb 26, 2011
Messages
53
Hi, I have a range of names in a list (A2 through G5). i am trying to do the following, If I have the name Peter in Cell C4 and I click on C4 I want the name Peter to appear in Cell A1. I would also like to be able to then click on the word Gary in Cell G2 and Gary would replace Peter in A1.

If anybody has any ideas as to how I can do this or point me in the right direction I would be most grateful.

Thanks

Peter
 

Some videos you may like

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
55,916
Office Version
  1. 365
Platform
  1. Windows
Try this Event Procedure VBA code.

Just right-click on the sheet tab name at the bottom of the screen, click "View Code", and paste this VBA code in the resulting VB Editor window:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)


'   Check to see only one cell is selected
    If Target.Count = 1 Then
'       Check to see if value selected is in range A2:G5
        If Not Intersect(Target, Range("A2:G5")) Is Nothing Then
'           If so, place value in A1
            Range("A1") = Target
        End If
    End If


End Sub
 

Peter083

Board Regular
Joined
Feb 26, 2011
Messages
53
Try this Event Procedure VBA code.

Just right-click on the sheet tab name at the bottom of the screen, click "View Code", and paste this VBA code in the resulting VB Editor window:
Code:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)


'   Check to see only one cell is selected
    If Target.Count = 1 Then
'       Check to see if value selected is in range A2:G5
        If Not Intersect(Target, Range("A2:G5")) Is Nothing Then
'           If so, place value in A1
            Range("A1") = Target
        End If
    End If


End Sub

Thank you Joe4,

I will try it.
 

Watch MrExcel Video

Forum statistics

Threads
1,122,469
Messages
5,596,315
Members
414,053
Latest member
Dual Showman

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
Top