Thread: HELP Debug
View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
[email protected] youu917@gmail.com is offline
external usenet poster
 
Posts: 29
Default HELP Debug

With Range("B1:B100")
Set FoundJurong = .Find(What:="Jurong", LookAt:=xlPart)
Set FoundTPY = .Find(What:="Toa", LookAt:=xlPart)
If Not FoundJurong Is Nothing Then

FoundJurongStart = FoundJurong.Row

For x = 1 To 100
Set FoundJurong = .FindNext(FoundJurong) 'jurong
FoundJurongEnd = FoundJurong.Row + 1 'jurong

Next
End If
If Not FoundTPY Is Nothing Then
FoundTPYStart = FoundTPY.Row


For x = 1 To 100

Set FoundTPY = .FindNext(FoundTPY) 'Toa Payoh
FoundTPYEnd = FoundTPY.Row + 1 'Toa Payoh
Next
End If
End With
Dim r As Variant
For r = FoundJurongStart To FoundJurongEnd 'jurong
If TextBox1.Value = Sheet6.Cells(r, 1).Value Then
Label1.Visible = True
End If
Next
For r = FoundTPYStart To FoundTPYEnd 'TPY
If TextBox1.Value = Sheet6.Cells(r, 1).Value Then
Label3.Visible = True
End If
Next
End Sub

It is a search button that will search the data in under 2 groups:
'Jurong' and 'Toa'.When clicked the search button, it will search the
data( keyed in textbox1) in 'sheet6' and then change the visibility of
labels.if the data is under 'jurong' group, label 1 will become
visible, if data is under 'Toa' group, label3 will become visible.
I'm wondering why the code above cannot run properly but if i only
search for 1 part( i.e: i delete all the codes regarding 'TPY, and
search the data in 'Jurong' group), it will work properly.