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
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN

Joe4

MrExcel MVP, Junior Admin
Joined
Aug 1, 2002
Messages
63,304
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.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,089
Messages
5,835,333
Members
430,351
Latest member
ddalton

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