LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Can this be simplified?

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Simplified SUMIF Needed Funkydan Excel Discussion (Misc queries) 11 August 22nd 07 03:11 PM
Simplified Date Entry? Brainfire Excel Discussion (Misc queries) 3 December 6th 06 06:46 AM
looking for simplified formulas philip Excel Worksheet Functions 6 June 7th 06 03:03 AM
Can this be simplified Barb Reinhardt Excel Worksheet Functions 3 October 4th 05 02:35 PM
Simplified Help Michael168[_47_] Excel Programming 6 November 4th 03 09:30 PM


All times are GMT +1. The time now is 10:23 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"