• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA code

Manny

New Member
Hello,
I have a workbook with 2 worksheets - Work_Order & Customer_Database. I would like to search for the value in M2(Work Ord No) of the Work_Order worksheet and perform a vlookup in column A of Customer_Database worksheet; if it finds the value, then I would like to display "PO Number Already Exists", otherwise, it will go into a loop until the last empty cell in column A and then copy the range V2:AP2 from Work_Order worksheet and paste in the last empty cell(column A) of Customer_Database worksheet.

I know how to copy and paste the range, as well as to perform the loop.
I have the following code:

Sub Save_Cust_Info()

Application.ScreenUpdating = True 'False

Sheets("Work_Order").Columns("T:AQ").EntireColumn.Hidden = True
Range("V2:AP2").Select
Selection.Copy
Sheets("Customer_Database").Select
Range("A1").Select
ActiveCell.Offset(1, 0).Select
Do While Not IsEmpty(ActiveCell)
ActiveCell.Offset(1, 0).Select
Loop
Selection.PasteSpecial Paste:=xlPasteValuesAndNumberFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False 'This line is utilized to overwrite existing data and also formats the data, removes coloring
Application.CutCopyMode = False
Sheets("Work_Order").Select
Range("Work_Ord_No").Select

'Application.Quit
End Sub



Thanks in advance for your help.
Best,
Manny
 

Attachments

  • PO_WorkBook.xlsm
    30.7 KB · Views: 2
Hi Manny,

Find the attached workbook as per your requirment.

Regards
Abdul Matheen
 

Attachments

  • PO_WorkBook (1).xlsm
    28.6 KB · Views: 4
Hi Abdul,
Thank you so much for your help. It works just like intended.
I greatly appreciate your help.
Best regards,
Juan
 
Back
Top