When creating the next macro to copy, from one sheet to another only the cells that meet the condition, the execution shows me this error:
"error '13': the types do not match"
Code:
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?