Consulting

Results 1 to 2 of 2

Thread: VBA Macro Help

  1. #1
    VBAX Newbie
    Joined
    Dec 2012
    Posts
    1
    Location

    VBA Macro Help

    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

  2. #2
    VBAX Regular
    Joined
    Aug 2011
    Posts
    87
    Location
    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.

    [vba]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[/vba]
    Regards
    Osvaldo

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •