Replicate cell contents when a value is enter

Closed
TexasTom - Oct 8, 2009 at 04:11 AM
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 - Oct 8, 2009 at 10:15 PM
Hello,

Thanks in advance for any/ all help and advice provided
I'm using Office 2007 XP Pro

What I want is if a string value is entered into cell a1 (32 possible values) then displayed in a1 would be the contents of cell c1:c32.
so if i enter "1" the contents (another string) of c1 is displayed,
if 16 then contents of c16 is displayed.

Again all help is gratefully received.
Thnks
Tom

2 responses

venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 8, 2009 at 06:13 AM
let me rephrase the question to see whether I have understood.

C1 to C32 have entries 1 to 32ed
If enter 1 in A1 C1 is selectd.
If now enter 5 in A1 c5 is selected
if now I enter 16 c16 is selected

right click the sheet tab
click view code
in the resulting window copy paste this event code

Private Sub Worksheet_Change(ByVal Target As Range)

If Target.Address <> "$A$1" Then Exit Sub
Columns("C:C").Cells.Find(what:=Target.Value, lookat:=xlWhole).Activate

End Sub


If this solves the problem post back "YES"
0
Hi, Thanks for your input.

What I actually have is in column "O" 32 names
what i want to be able to do is in the whole of column "B" is to be able to type a number 1-32 in various and possibly repeating cells and when the number 6 is entered the cell is actually populated with the 6th name in column "O" and number 31 returns the 31st name.

Your solution meant that when I entered a number the cell that was in focus was the one containing the matching number.

Thanks again.
Tom
0
venkat1926 Posts 1863 Registration date Sunday June 14, 2009 Status Contributor Last seen August 7, 2021 811
Oct 8, 2009 at 10:15 PM
You could have cleared this in your first posting itself .

see the modified macro with the same instructions
I have used the column c. for my easy verification
you can change wherever "c" comes into "O"

the event code is

Private Sub Worksheet_Change(ByVal Target As Range)
Dim r As Range, x As String, j As Integer
Application.EnableEvents = False
If Target.Address <> "$A$1" Then GoTo line1

Set r = Range(Range("C1"), Range("c1").End(xlDown))
j = Range("A1").Value
x = Cells(j, "c")
Range("A1") = x
line1:
Application.EnableEvents = True
End Sub
0