venson0801
07-16-2010, 11:36 AM
Hey guys, I have created a sub, intend to find the some certain text and move to the bottom of the category. The code works fine if I could find the existing category. I want a messagebox pop out if they didn't find it, but the problem is that my code never goes to the else section of the code. Could someone please tell me what's wrong with the code? Thanks so much!
Here is the code:
Private Sub LookUpType()
Dim datatoFind3, g, currentRow
datatoFind3 = cbotype.Value
g = Cells.Find(What:=datatoFind3, After:=[A1], LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
If g = "True" Then
ActiveCell.Offset(1, 6).Select
Do While ActiveCell.Value = datatoFind3
ActiveCell.Offset(1, 0).Select
Loop
Else
MsgBox ("New Category")
End If
ActiveCell.EntireRow.Insert shift:=xlDown
End Sub
Here is the code:
Private Sub LookUpType()
Dim datatoFind3, g, currentRow
datatoFind3 = cbotype.Value
g = Cells.Find(What:=datatoFind3, After:=[A1], LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False).Activate
If g = "True" Then
ActiveCell.Offset(1, 6).Select
Do While ActiveCell.Value = datatoFind3
ActiveCell.Offset(1, 0).Select
Loop
Else
MsgBox ("New Category")
End If
ActiveCell.EntireRow.Insert shift:=xlDown
End Sub