Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default functions or vba solution

Nothing came out from Functions maybe here?

Sheet1 - logged ticket books to sales persons

name beginno endno
a 51 100
b 101 150


I do below checks by vba if user makes a wrong entry say


d 75 - msgbox " Number already in use "
e 151 141 msgbox " Wrong entry"


But couldn't do below check


f 1 200 msgbox " Numbers already in
use"


Any help ? Thank you

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default functions or vba solution

Try this.

Private Sub Worksheet_Change(ByVal Target As Range)
Dim rng As Range
Dim c As Range
Dim iCt as Long
If Target.Column = 2 And Target < "" Then
Set rng = Range("B2:B" & Target.Row - 1)
For Each c In rng
If Target = c And Target <= c.Offset(0, 1) Then
MsgBox "Error. Number already in use."
Target = ""
End If
Next c
End If
If Target.Column = 3 And Target < "" Then
If Target < Target.Offset(0, -1) Then
MsgBox "Error. End number must be = begin number."
Target = ""
Exit Sub
End If
Set rng = Range("B2:B" & Target.Row - 1)
For iCt = Target.Offset(0, -1) + 1 To Target
For Each c In rng
If Target = c And Target <= c.Offset(0, 1) Then
MsgBox "Error. Number(s) already in use."
Target = ""
End If
Next c
Next iCt
End If
End Sub

Hth,
Merjet


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default functions or vba solution

Thank you very much Merjet.
One more thing though:
How can I avoid flying over numbers ?

Like 1 to 200 ?


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 812
Default functions or vba solution

How can I avoid flying over numbers ?
Like 1 to 200 ?


Oops.
Change: If Target = c And Target <= c.Offset(0, 1)
To: If iCt = c And iCt <= c.Offset(0, 1)

Merjet


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 22
Default functions or vba solution

Exactly what I needed ! Thank you vey much.
Kind regards

Reply
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
Nesting MATCH functions? Or other solution? KCobler Excel Worksheet Functions 2 February 24th 09 09:08 PM
Looking for a better solution ibvalentine Excel Worksheet Functions 20 November 5th 08 04:49 PM
solution wants shoyeb2045 Excel Discussion (Misc queries) 4 August 14th 08 08:34 PM
Best Fit Solution Tom Ogilvy Excel Programming 0 August 26th 04 05:34 PM
Is there a solution? Mike Excel Programming 0 March 2nd 04 11:42 PM


All times are GMT +1. The time now is 02:45 AM.

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

About Us

"It's about Microsoft Excel"