#1   Report Post  
Posted to microsoft.public.excel.programming
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.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,986
Default HELP Debug

With Range("B1:B100")
Set FoundJurong = .Find(What:="Jurong", 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
Set FoundTPY = .Find(What:="Toa", LookAt:=xlPart)
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


" wrote:

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.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default HELP Debug

On 2ÔÂ12ÈÕ, ÉÏÎç12ʱ04·Ö, JLGWhiz wrote:
With Range("B1:B100")
Set FoundJurong = .Find(What:="Jurong", 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
Set FoundTPY = .Find(What:="Toa", LookAt:=xlPart)
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



" wrote:
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.- Òþ²Ø±»ÒýÓÃÎÄ×Ö -


- ÏÔʾÒýÓõÄÎÄ×Ö -


Thank you very much
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default HELP Debug

Can anyone tell me how to do this kind of programming? i made sure it
can work under 1 search, then i tried to copy the code and make a
little change to search for another groups of words. however, it
always occur error and didn't work properly. Can anyone give me a
suggestion on how to do the programming so that if i want to add
another new search, i can just copy the old code and make a little
change and it will work.
thank you

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
Debug this Al Excel Programming 0 November 14th 06 07:16 PM
How To Use Debug Minitman[_4_] Excel Programming 4 January 18th 06 05:42 PM
help with debug Rusty New Users to Excel 3 February 2nd 05 03:16 AM
Debug VBA Paul Cowan Excel Programming 0 December 9th 04 01:11 PM
* How do we debug this? ... Kris Excel Programming 2 October 29th 04 02:17 AM


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