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: 1
Default Checking Input box


I'm trying to verify input given via an input box:

Code
-------------------
Sub copyData()
Dim varNameInput As String
myNameInput = Application.InputBox(prompt:="Enter a sheet name", _
Title:="Sheet Name", Type:=2)
Do While myNameInput = ""
MsgBox "You didn't enter a sheet name!", 16
myNameInput = Application.InputBox(prompt:="Enter a sheet name", _
Title:="Sheet Name", Type:=2)
Loop
If Not myNameInput = False Then
MsgBox myNameInput
End If
Exit Sub
End Su
-------------------


This works, however... Because I can't quite translate what's in m
mind into VBA, I'm stuck with the following cases which should al
trigger a failure MsgBox and repeat the loop:

- If the user enters a white space
- If the user enters a name with a white space
- If the user enters a name that doesn't match any of the sheets i
the workbook.

The latter, if I'm not mistaken, I need to do with Intersect, somethin
like (and please correct me if I'm wrong here):

Code
-------------------
If Not Intersect(myNameInput, Range("A1:A10")) is Nothing Then
... successful match, run necessary code ...
Else
... trigger failure again and go back to loop ...
End I
-------------------


I just don't know how to translate that into VBA.


And on a slightly different note, can an evaluation contain ORs? Fo
example, *If (myNameInput = "" || myNameInput = False || ...etc.) Then

--
AMK
-----------------------------------------------------------------------
AMK4's Profile: http://www.excelforum.com/member.php...fo&userid=1914
View this thread: http://www.excelforum.com/showthread.php?threadid=50432

 
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
checking input in a cell and return by copying info from a other c Golf-Iron7 Excel Worksheet Functions 4 February 27th 10 04:07 AM
Spell Checking with checking cell notes jfitzpat Excel Discussion (Misc queries) 0 August 8th 07 10:26 PM
checking input on a textbox in userform to be a % Jean-Pierre D via OfficeKB.com Excel Programming 11 August 25th 05 11:39 PM
Checking input for alphabet (i.e. words) Neal[_5_] Excel Programming 1 February 12th 04 01:50 AM
CODE to select range based on User Input or Value of Input Field Sandi Gauthier Excel Programming 4 December 8th 03 03:22 PM


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