How to add IF in this case?

Viewed 46

I need some help, dont know if the thing i wanna do its possible..

I Have this macro:

Sub AUMENTAR()

    Dim NFILA As Integer
    
    Sheets("PRODUCTOS").Range("A8").Select

    NFILA = Sheets("PRODUCTOS").Cells(Rows.Count, "A").End(xlUp).Row
    
    
    Range("K8:K" & NFILA).Select
    Selection.Copy
    
    Range("D8").PasteSpecial xlPasteValues
    
    Application.CutCopyMode = False
    
    MsgBox "Los precios fueron aumentados en un " & Range("AUMENTO").Value & " correctamente."

End Sub


The macro its in this button "AUMENTAR", basically this adds a + x% to the prices on the "D" Column.

Image

Its there any way to make an if to..

Get the string of G4 (PROVEEDORNUMERO1) and compare to "B" Column.. and adds x% only to the cells that match, and dont change the price to the cells that dont match?

The thing is that i have a lot of providers, and wanna change the G4 string so the macro can change values of that provider only.

1 Answers

Seems like an elementary problem? Here's an "IF" statement.

Sub Sub1()
  Dim iRow&, iCol&
  Cells(1, 1) = "P01"
  For iRow = 3 To 5
    If Cells(iRow, 1) = Cells(1, 1) Then Cells(iRow, 2) = Cells(iRow, 2) * 1.1 ' +10%
  Next iRow
End Sub
Related