ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,832
- Office Version
- 2007
- Platform
- Windows
I have a code which works on a worksheet fine.
I then copied it to another worksheet in a different workbook BUT i kept seeing an error saying Not Defind.
The line when debugged is shown below in Blue.
So i added the Line of code in Red & works fine.
My question is Why when on the other sheet does it run WITHOUT the code in Red & Blue ?
Should i be using the code below also on the other sheet ?
Thanks
I then copied it to another worksheet in a different workbook BUT i kept seeing an error saying Not Defind.
The line when debugged is shown below in Blue.
So i added the Line of code in Red & works fine.
My question is Why when on the other sheet does it run WITHOUT the code in Red & Blue ?
Should i be using the code below also on the other sheet ?
Thanks
Rich (BB code):
Private Sub FindDog_Click()
Dim myRange As Range
Dim myCell As Range
Set myRange = Range("Table2").ListObject.DataBodyRange ' CHANGE TABLE NAME
For Each myCell In Intersect(Columns("C"), myRange) ' CHANGE COLUMN LETTER FOR WHERE TO LOOK FOR VALUE
If myCell.Value = "BUDDY" Then ' CHANGE NAME OF WHAT TO LOOK FOR
With Range("A" & myCell.Row) ' SELECT CUSTOMER IN COLUMN A ONCE FOUND
If MsgBox("BUDDY LOCATED AT ROW: " & myCell.Address(0, 0) & vbCr & vbCr & _
"THE CUSTOMER IS : " & .Value & vbCr & vbCr & _
"IS THIS WHAT YOU ARE LOOKING FOR ?", vbCritical + vbYesNo, "FIND BUDDY") = vbYes Then ' CHANGE TEXT TO SUIT
.Select
Exit Sub
End If
End With
End If
Next myCell
MsgBox "THERE ARE NO TO BE FOUND" & vbNewLine & vbNewLine & "SO THE SEARCH IS NOW COMPLETE", vbInformation, "FIND BUDDY MESSAGEE" ' CHANGE TEXT TO SUIT
Range("A2").Select
End Sub