Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I include a wider range in my code??

I have the following input box running when a workbook is open...

Sub ZipCode()
MyInput = InputBox("Please enter Zip Code")
If MyInput = "10023" Then Worksheets("Sheets").Select
If MyInput = "10024" Then .... and so on for the whole NYC metro area
End Sub

Now want to create a message box for the zip codes that are not
included for example 00000,99999,66666. How do I accomplish this in few
lines of code???

I started with the following... but this is obviously illegal.... I
don't know how to include a wider range of values....

Sub ZipCode()
If MyInput = "22222 to 99999" Then MsgBox "Area NOT covered",
vbOKOnly, "TRY AGAIN!"
End Sub

Can any1 help??


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default How do I include a wider range in my code??

nrage21 < wrote:
Sub ZipCode()
If MyInput = "22222 to 99999" Then MsgBox "Area NOT covered",
vbOKOnly, "TRY AGAIN!"
End Sub


Replace MyInput = "22222 to 99999" with:

Val(Myinput) = 22222 And Val(MyInput) <= 99999

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I include a wider range in my code??

Thx Beto.

I found another way by experimenting....

Sub ZipCode()
MyInput = InputBox("Please enter Zip Code")
If MyInput = "10023" Then Worksheets("Sheet2").Select
If MyInput = (22222) < (99999) Then MsgBox "Area NOT covered",
vbOKOnly, "TRY AGAIN!"
End Sub

Any # between 22222 and 99999 will trigger the msgbox. :)


---
Message posted from http://www.ExcelForum.com/

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How do I include a wider range in my code??

Never mind my last post code goes AWOL, doesnt wor

--
Message posted from http://www.ExcelForum.com

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 140
Default How do I include a wider range in my code??

nrage21 < wrote:
I found another way by experimenting....

Sub ZipCode()
MyInput = InputBox("Please enter Zip Code")
If MyInput = "10023" Then Worksheets("Sheet2").Select
If MyInput = (22222) < (99999) Then MsgBox "Area NOT covered",
vbOKOnly, "TRY AGAIN!"
End Sub

Any # between 22222 and 99999 will trigger the msgbox. :)


Are you sure?
I tried your code and the message box pop-ups everytime, with any
argument. The condition is always true...

Regards,
--
Beto
Reply: Erase between the dot (inclusive) and the @.
Responder: Borra la frase obvia y el punto previo.



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
Use RANDBETWEEN form & include certain #'s in the range texas7186 Excel Worksheet Functions 15 December 13th 09 12:43 AM
Create PDF from XLS by VB Code using PDFMaker include Bookmarks Koulla Excel Discussion (Misc queries) 1 February 25th 08 08:47 AM
Code to include a one-up suffix to a field value Doctorjones_md Excel Discussion (Misc queries) 4 January 4th 07 06:18 PM
Code to include a one-up suffix to a field value Doctorjones_md Excel Worksheet Functions 4 January 4th 07 06:18 PM
Include a password in VB code. GA Excel Discussion (Misc queries) 6 March 23rd 06 07:36 AM


All times are GMT +1. The time now is 12:03 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"