Results 1 to 2 of 2

Paste range of cells that meet criteria

Threaded View

  1. #1
    Registered User
    Join Date
    11-08-2012
    Location
    Mexico
    MS-Off Ver
    Excel 2010
    Posts
    28

    Paste range of cells that meet criteria

    Hi,
    I'm having trouble with the programming of my macro. I have the following code

    Sub Liquidacion_Factura1() 'para pegar la fecha liquidación
    Dim Conc As Workbook, Conc1 As Worksheet
    Dim Liq1 As Worksheet
    Dim Z As Integer
    
    Set Conc = ActiveWorkbook
    Set Conc1 = Sheets("Sheet1")
    Conc1.Select
    
    Set Liq1 = Sheets("Sheet2")
    Liq1.Select
    
    Z = 1 + Application.WorksheetFunction.CountA(Range("A2:A999999"))
    
    For x = 2 To Z                 'Liquidación
    For y = 2 To 999999            'Consolidado
    
    
    
    If Liq1.Cells(x, 6) = "" Then
    Exit For
    End If
    
    If Liq1.Cells(x, 1) & Liq1.Cells(x, 2) & Liq1.Cells(x, 3) = Conc1.Cells(y, 1) & Conc1.Cells(y, 2) & Conc1.Cells(y, 3) Then
    Liq1.Cells(x, 6).Select
    Selection.Copy
    Conc1.Activate
    Conc1.Cells(y, 4).Select
    Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone, SkipBlanks:=False, Transpose:=False
    Liq1.Activate
    
    Exit For
    End If
    
    Next y
    Next x
    
    End Sub
    The thing is I have in Sheet 1 several rows with the same information. The macro only copies the Cell from Sheet 2 to the first cell in Sheet 1 if it identifies matching the criteria. How can I modify the code so that the macro copies it to all the cells in Sheet 1.

    I attach an example of my worksheet.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1