Thread: Loop help
View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default Loop help

Dim myString As Range
Dim TrimString As String

For Each myString In Range("B2:B10")
TrimString = Trim(myString)

If Len(TrimString) = 16 Or Len(TrimString) = 10 Then
Else

MsgBox "Cell: " & myString.Address & ", Value: " &myString & _
"incorrect, doesnt equal 16 or 10, please enter a correct value:"

myString.Select
myString = InputBox("Enter the correct value")
End If

Next myString
MsgBox "finished!"
Unload Me

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"benjammind" wrote
in message ...

Thanks for the responses, one thing I forgot to add, once I have
identified, and shaded, the particular cell I want excel to jump/scroll
down to that particular cell.

For example if cells 1 - 49 are displayed on the screen and the code
highlights cell A189 I want excel to go to this location
automatically.

Again, your help is appreciated.
Ben


--
benjammind
------------------------------------------------------------------------
benjammind's Profile:

http://www.excelforum.com/member.php...o&userid=18217
View this thread: http://www.excelforum.com/showthread...hreadid=556417