Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi everybody,
I made a small VB procedure in Excel. It controls a list of 12 cells containing numbers. It sees to it that no duplicate numbers can be in the list: if the user inserts a number that is already there, the previous number is reased. The procedure works ok. But I am sure that it can be made a little more simple, for instance by using a FOR loop or perhaps a FOR EACH loop. Does anybody know how? This is the listing: Private Sub Worksheet_Change(ByVal Target As Range) If Target.Count = 1 Then Application.EnableEvents = False v = Target.Value r = Target.Row If Range("c8").Row < r And Range("c8").Value = v Then Range("c8").Value = "" If Range("c9").Row < r And Range("c9").Value = v Then Range("c9").Value = "" If Range("c10").Row < r And Range("c10").Value = v Then Range("c10").Value = "" If Range("c11").Row < r And Range("c11").Value = v Then Range("c11").Value = "" If Range("c12").Row < r And Range("c12").Value = v Then Range("c12").Value = "" If Range("c13").Row < r And Range("c13").Value = v Then Range("c13").Value = "" If Range("c14").Row < r And Range("c14").Value = v Then Range("c14").Value = "" If Range("c15").Row < r And Range("c15").Value = v Then Range("c15").Value = "" If Range("c16").Row < r And Range("c16").Value = v Then Range("c16").Value = "" If Range("c17").Row < r And Range("c17").Value = v Then Range("c17").Value = "" If Range("c18").Row < r And Range("c18").Value = v Then Range("c18").Value = "" If Range("c19").Row < r And Range("c19").Value = v Then Range("c19").Value = "" Application.EnableEvents = True End If End Sub Thanks! Niko |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Simplified SUMIF Needed | Excel Discussion (Misc queries) | |||
Simplified Date Entry? | Excel Discussion (Misc queries) | |||
looking for simplified formulas | Excel Worksheet Functions | |||
Can this be simplified | Excel Worksheet Functions | |||
Simplified Help | Excel Programming |