Macro

J

jim802091

How would i write a macro or script. I have 2 lists of text and want
to click on a cell in list 1 and have the text show up in the cell at
the bottom of list 2. And be able to repeat the procedure.

jim802091
 
T

Tom Ogilvy

Assume to named ranges, List1 and List2. List2 is on Sheet2
In the sheet with List1

Right click on the sheet tab and select view code

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)

End Sub


put in code like

Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
Dim rng As Range, rng1 As Range
If Target.Count > 1 Then Exit Sub
If Not Intersect(Target, Range("List1")) Is Nothing Then
Set rng = Worksheets("Sheet2").Range("List2")
Set rng1 = rng(1).End(xlDown)(2)
rng1.Value = Target.Value
rng.Resize(rng.Rows.Count + 1).Name = "List2"
End If
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top