Help in macro excel

0

I need to know how, after fulfilling the condition, you can copy the corresponding range and paste on another sheet. That is, if row 13, after the iteration arrives, fulfills the condition, the defined range of row 13 is copied and copied in the defined range of another sheet.

Sub CondicionalTopTxx()

Dim OrigenHoja As Excel.Worksheet, _
    DestinoHoja As Excel.Worksheet, _
    a As Integer

Set OrigenHoja = Worksheets("TNC D")
Set DestinoHoja = Worksheets("TNC B")

OrigenHoja.Activate

    For a = 2 To 40

    Set valor = OrigenHoja.Cells(a, 17)

      If valor.Value < 4 Then

      Range("O14:S16").Copy
      DestinoHoja.Range("O14:S16").PasteSpecial xlPasteAll
      Application.CutCopyMode = False

      End If

    Next

End Sub

How can I select only the range that meets the condition? Thanks.

    
asked by Calej 21.05.2018 в 12:58
source

1 answer

0

Assuming a is the number of the row in which we are:

Range(Cells(a,15),Cells(a,19)).Copy 

With this you should always select the range where you are evaluating the condition.

    
answered by 22.08.2018 в 15:52