#1   Report Post  
Posted to microsoft.public.excel.programming
FGM FGM is offline
external usenet poster
 
Posts: 35
Default InStr

Excel Microsoft XP on Windows 200

I am using a form as a utility for a group of macros and one of the text
filelds on form asks for the column and row to start the searh in ex. b2

I want to be able to check with vb that the user put both a numeric key and
a alpha key, better yet I would like to check that it is a valid address.

Any suggestions...

Thank you in advance....
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,441
Default InStr

FGM,

For example:

Dim myRange As Range
On Error GoTo Badstring:
Set myRange = Range(UserForm1.TextBox1.Text)
MsgBox "Good string"
Exit Sub
Badstring:
MsgBox "That was bad."

HTH,
Bernie
MS Excel MVP


"FGM" wrote in message
...
Excel Microsoft XP on Windows 200

I am using a form as a utility for a group of macros and one of the text
filelds on form asks for the column and row to start the searh in ex. b2

I want to be able to check with vb that the user put both a numeric key and
a alpha key, better yet I would like to check that it is a valid address.

Any suggestions...

Thank you in advance....



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default InStr

Just check it really is a range

Private Sub CommandButton1_Click()
Dim rng As Range
On Error Resume Next
Set rng = Range(TextBox1.Value)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Input a valid range (A1, B1,AB99 etc.)"
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If
End Sub


or use a RefEdit control.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"FGM" wrote in message
...
Excel Microsoft XP on Windows 200

I am using a form as a utility for a group of macros and one of the text
filelds on form asks for the column and row to start the searh in ex.

b2

I want to be able to check with vb that the user put both a numeric key

and
a alpha key, better yet I would like to check that it is a valid address.

Any suggestions...

Thank you in advance....



  #4   Report Post  
Posted to microsoft.public.excel.programming
FGM FGM is offline
external usenet poster
 
Posts: 35
Default InStr

thank you... you guys are great..

"Bob Phillips" wrote:

Just check it really is a range

Private Sub CommandButton1_Click()
Dim rng As Range
On Error Resume Next
Set rng = Range(TextBox1.Value)
On Error GoTo 0
If rng Is Nothing Then
MsgBox "Input a valid range (A1, B1,AB99 etc.)"
With TextBox1
.SelStart = 0
.SelLength = Len(.Text)
.SetFocus
End With
End If
End Sub


or use a RefEdit control.

--

HTH

RP
(remove nothere from the email address if mailing direct)


"FGM" wrote in message
...
Excel Microsoft XP on Windows 200

I am using a form as a utility for a group of macros and one of the text
filelds on form asks for the column and row to start the searh in ex.

b2

I want to be able to check with vb that the user put both a numeric key

and
a alpha key, better yet I would like to check that it is a valid address.

Any suggestions...

Thank you in advance....




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
Help with VBA InStr() function EagleOne Excel Discussion (Misc queries) 10 April 12th 07 02:47 PM
InStr function question [email protected] Excel Programming 9 June 28th 05 03:03 PM
InStr and ADO Al Excel Programming 2 June 17th 04 04:22 PM
instr isn't finding all the matches Bob Phillips[_6_] Excel Programming 2 February 25th 04 01:12 PM
InStr used in SQL query dchow Excel Programming 3 July 21st 03 09:09 AM


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