Macro or script

J

JIM80215

Could i find out how to write a macro or script. I want to click on
one or more cells in a range containing text and have that text copied
to the bottom of a second range.and be able to repeat that procedure.

thank you
jim 80215
 
T

Tom Ogilvy

Seems like you posted this in Worksheet.functions yesterday.

Assume two 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