Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Debug this | Excel Programming | |||
How To Use Debug | Excel Programming | |||
help with debug | New Users to Excel | |||
Debug VBA | Excel Programming | |||
* How do we debug this? ... | Excel Programming |