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

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
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
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,213,546
Messages
6,114,254
Members
448,556
Latest member
peterhess2002

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