Comparar com planilha diferentes e manipular dados correspondentes

Adonias

16-07-2020 03:16:06

Essa eu me enrolei no básico.
Até consigo com FormulaR1C1, mas não consegui manter a linha de referência

Segue plan

Raygsson

16-07-2020 03:51:56

seu problema é simples, no geral pode ser algo assim:

Código: Selecionar todos

Sub comparar()
Dim lin As Long, lin2 As Long
Dim prod As String, prod2 As String
Dim total As Double

lin = 2
Do While Planilha2.Range("A" & lin) <> ""
prod = Planilha2.Range("A" & lin)

    lin2 = 2
    Do While Planilha1.Range("A" & lin2) <> ""
    prod2 = Planilha1.Range("A" & lin2)
    
        If LCase(prod) = LCase(prod2) Then
            total = Planilha1.Range("B" & lin2) * Planilha2.Range("B" & lin)
            
            If LCase(Planilha2.Range("C" & lin)) = "sim" Then total = total + (total * 0.15)
            
            Planilha2.Range("D" & lin) = total
        End If
    
    lin2 = lin2 + 1
    Loop

lin = lin + 1
Loop

End Sub