Consulting

Results 1 to 3 of 3

Thread: Copy paste values from another workbook if criteria is met

  1. #1

    Copy paste values from another workbook if criteria is met

    Hello all,

    I am trying to come up with a program that is able copy the values in the cells of column A of workbook 1, IF the value in the cells of column J for that row is "Customer A". And afterwards, paste it into cell A2 of workbook 2.

    I've came up with the following program but I've hit a roadblock.

    Dim x As workbook 
    Dim y As workbook 
    Dim lastrow As Integer 
    Dim i As Integer 
     
    Set x =workbooks.open("D:\......Workbook 1") 
    With x.sheets("sheet 1") 
        lastrow = activesheet.range("A" & Rows.Count).End(xlUp).Row 
         
        For i = 2 To last row 
            If range("J" & i).value = "Customer A" Then 
                 'how to copy this value or select it ?
            End If 
        Next i 
    End With 
     
    Set y = workbooks.open("D:\......Workbook 2") 
    With y.sheets("sheet1") 
         'paste the copied values in range("A2")
    
    
    Formatting tags added by mark007
    Thank you in advance for the help provided

  2. #2
    Sub test() 
         
         
        With Workbooks.Open("D:\......Workbook 1").Sheets("sheet 1").Range("A1").CurrentRegion 
            .AutoFilter 
            .AutoFilter 10, "Customer A" 
            If .Columns(1).SpecialCells(xlCellTypeVisible).Count > 1 Then 
                .Offset(1).Copy Workbooks.Open("D:\......Workbook 2").Sheets("sheet1").Range("A2") 
            End If 
            .AutoFilter 
        End With 
         
    End Sub 
    
    
    Formatting tags added by mark007

    マナ

  3. #3
    -I HAVE NO IDEA WHAT I'M DOING

Posting Permissions

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