PDA

View Full Version : If it finds "Customer" then run code if it dosen't skip code



Djblois
07-05-2006, 08:12 AM
Please don't get tired with me everyone, it is really coming along. lol Thank you all for your help. Now, I want to check if it finds "Customer" and if it does then run some code, if it dosen't skip the code and go on the next part of the macro.

compariniaa
07-05-2006, 08:20 AM
if it finds customer where? in each row or column, or just once on the entire worksheet?

Djblois
07-05-2006, 08:29 AM
In a particular Column. Here is the code I am using:

Detail.Columns("A:A").Find(What:="Customer:").Select
Detail.Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Cut
If WB.Sheets.Count = 1 Then
Set Cust = WB.Worksheets.Add
Else: Set Cust = WB.Sheets(2)
End If
ActiveSheet.Name = "Cust"
ActiveSheet.Paste

compariniaa
07-05-2006, 08:48 AM
before the detail.columns part, insert this:

On error goto No_Customer
'this is followed by your customer code
put in the GoTo line (No_Customer: ) right before where
you want the macro to continue
No_Customer:
'the next part of the macro goes here

Djblois
07-13-2006, 09:49 AM
That will work but what if I want it to run this code if it finds customer in the row and this code if it doesn't. Then how do I get that code to work for that?

mdmackillop
07-13-2006, 11:41 PM
Dim c As Range
Set c = Columns("A:A").Find(What:="Customer:")
If c Is Nothing Then
MsgBox "Not found"
Else
MsgBox c.Address
End If
Set c = Nothing