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.
Bookmarks