PDA

View Full Version : VBA Macro Help



Mike_Bio
12-27-2012, 10:07 PM
I am trying to create a macro to do the following:

Conditions:
workbook1 contains a value in cell A4 with related data in cell D4 i need to copy to a seperate workbook.
Workbook3 contains a list of values in column B that match the value in workbook1 cell A4. The list of values in workbook 3 are unique.

Proceedure:
I need to use the value in workbook1 cell A4 to find the related row of data in workbook3 in column B, then copy workbook1 cell D4 to the related row of data in workbook3 offset from column B by 15 columns.

Any help would be appricaited

Mike

omp001
12-28-2012, 04:38 PM
Hello Mike.
See if this code could be a start point. Install it in a standard module of the Workbook1 and run it from WB1 or WB3, any sheet.

Sub CopyData()
Dim ws1 As Worksheet, ws3 As Worksheet, k As Long
Set ws1 = ThisWorkbook.Sheets("Sheet1") 'replace sheet name if needed
Set ws3 = Workbooks("Workbook3").Sheets("Sheet1") 'replace sheet name if needed

With ws3
k = .[B:B].Find(ws1.[A4]).Row
.Cells(k, "Q") = ws1.[D4]
End With

End Sub