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: 161
Default Select Case not working - Why?

Hi,

Hopefully someone can explain why the code below does not work.

I have a list of names in column A that I am searching, using a string
captured from a form. What should happen is that the rSearch runs round the
Do..Loop until its value is the same as sName, in which case it does some
stuff (the Goto) and trminated the loop. Alternatively, it comes to a blank
cell (indicating the end of the list - ther are no spaces in the data), in
which case it produces an error message and terminates the loop. the msgbox
at the end is there so that I could try to work out what was happening and
shows that the correct value of sName and rSearch are being loaded, it's just
that the case statement does not kick in. The code does not generate any
errors, it simply terminates at the end of the list.

Dim sName As String ' name - entered by user
Dim rSearch As Range ' search pointer
Dim iCtr As Integer ' counter - used in various places

Set rSearch = Sheets("database").Range("a2")
Do
Select Case rSearch.Value
Case rSearch.Value = sName
GoTo Pop_sheet
Exit Do
Case rSearch.Value = ""
MsgBox ("please enter a valid name")
Exit Do
Case Else
Set rSearch = rSearch.Offset(1, 0)
iCtr = iCtr + 1
End Select
MsgBox (sName & rSearch.Value)
Loop

TIA

Dave
 
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
Code not working, copy in Select Case section not copying over. DanielleVBANewbie Excel Programming 10 July 22nd 08 06:44 PM
Case without Select Case error problem Ayo Excel Discussion (Misc queries) 2 May 16th 08 03:48 PM
End Select without Select Case, Block If without End If errors Atreides Excel Programming 12 November 17th 06 05:10 PM
Select Case in VBA not working Ronald Dodge Excel Programming 3 September 11th 03 09:50 PM


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