Home |
Search |
Today's Posts |
#5
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
try this
Private Sub Workbook_SheetChange(ByVal Sh As Object, _ ByVal Target As Range) If Target.Column = 1 And Target.Row < 1 Then Set SearchRange = Range("A1:A" & (Target.Row - 1)) Set c = SearchRange.Find(what:=Target.Value, _ LookIn:=xlValues, lookat:=xlWhole) If c Is Nothing Then Range("D1").value = Target.Value End If End If End Sub "jlclyde" wrote: I am trying to go through a list after a new name has been added to the bottom. If it matches any of the other names then it will exit. If it does nto then it will copy it to D1. I knwo this works, but is there an easier way to do this? I have several columns I need to write this for and woudl prefer somethign easier. Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) If Target.Column = 1 Then Range("A1").Select Do Until Selection = Target.Row + 1 If Selection.Value = Target.Value Then Exit Sub Else Selection.Offset(1, 0).Select End If If Selection.Row = Target.Row Then Range("A" & Target.Row).Copy Destination:=Range("D1") Exit Sub End If Loop End If End Sub Thanks, Jay |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Code needs simplifying | Excel Worksheet Functions | |||
Simplifying VBA code | Excel Worksheet Functions | |||
simplifying routine | New Users to Excel | |||
Simplifying a formula | Excel Worksheet Functions | |||
Simplifying formula | Excel Discussion (Misc queries) |