-
If this do that, If not Do the other
Thank you all for your help. I got both of those macros working in my file. However, now I need to write code to Find "CRN", if it finds it I need it to run some code but if it doesn't find it I need it to run other code. Again, I know what column it is in but not the row.
Thank you,
Daniel
-
I have no idea to what you are referring. Can you put it in context?
-
Gladly, I am looking to find the word "Customer" in Column A if it finds it I need it to open a file and do a vlookup from that file. If it can't find it, skip that code and go to the rest of the macro.
Daniel
-
Hi Daniel,
Here's a sample
[VBA]
Sub FindLookup()
Dim ThsBook As Workbook, c As Range
Application.ScreenUpdating = False
Set ThsBook = ActiveWorkbook
Set c = Columns(1).Find(What:="Customer")
If Not c Is Nothing Then
Workbooks.Open "C:\AAA\VBA.xls"
ThsBook.Activate
c.Offset(, 2).FormulaR1C1 = "=VLOOKUP(RC[-2],[VBA.xls]Sheet1!C2:C5,4,FALSE)"
Exit Sub
End If
MsgBox "Customer not found"
Application.ScreenUpdating = True
End Sub
[/VBA]
MVP (Excel 2008-2010)
Post a workbook with sample data and layout if you want a quicker solution.
To help indent your macros try Smart Indent
Please remember to mark threads 'Solved'
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules