LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Verifying input

Dim rng as Range, res as Variant

If Not Intersect(Target, Range("A13:B90")) Is Nothing Then

If Target.Column = 1 Then
set rng = Worksheets("Items").Range("A:A")
res = application.Match(target,rng,0)
if iserror(res) then
msgbox "Bad entry, try again"
exit sub
end if
Target.Offset(, 1).Select 'advance to col B for qty
Else
Target.Offset(1, -1).Select 'advance to next row, col A for item
number
End If
End If

--
Regards,
Tom Ogilvy


"WLMPilot" wrote in message
...
I have a workbook that contains two sheets (Items, Order). The Order sheet
is what the user uses to input data to place an order, ie item number and
qty. The Items sheet list the item number and item description. I am
using
a macro to control cursor movement (left - right) for entering item
number
and qty before advancing to the next row for the next item.

I am trying to figure out how to check the item number entered by user
against the item numbers in the list on the Items sheet (A2:A300), to make
sure that the item number entered is valid.

Below is the code used to control cursor movement. It is within this code
that I need to validate the item number and NOT advance until a valid
number
is entered. I can figure out how to display a message box to notify user
of
incorrect number. Just need the code. NOTE: Prior to entering this area
of
code, Cell "A13" has already been selected via RANGE ("A13").Select.

If Not Intersect(Target, Range("A13:B90")) Is Nothing Then
If Target.Column = 1 Then
Target.Offset(, 1).Select 'advance to col B for qty
Else
Target.Offset(1, -1).Select 'advance to next row, col A for item
number
End If
End If

Also, when checking the list in the Items sheet, can A:A be used instead
of
A2:A300 in the event new items are added in order to not have to go back
and
edit the range to search in the macro?

Thanks,
Les



 
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
Look up a value from a row after verifying two other values Paul W Excel Worksheet Functions 11 September 1st 08 08:59 PM
Verifying value of a cell El Criollo Excel Discussion (Misc queries) 7 December 12th 06 10:21 AM
Verifying Printer with Excel VBA Craig[_21_] Excel Programming 3 September 9th 05 09:14 AM
Verifying Dates gilbert Excel Worksheet Functions 1 September 8th 05 03:22 AM
verifying date MacroMan Excel Programming 0 July 30th 03 10:38 PM


All times are GMT +1. The time now is 12:21 PM.

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"