venerdì 2 marzo 2018

vba Excel evidenzia Prezzi Diversi Preventivi Ddt

‘ vba Excel evidenzia Prezzi Diversi Preventivi Ddt

 

Sub evidenziaPrezziDiversiPreventiviDdt()

Dim quanterighe, contarighe, foglio

Dim prezzopreve, prezzoddt, mesepreve, meseddt

Set foglio = Sheets("DDT-preventivi")

'

quanterighe = Range(foglio.UsedRange.Cells(foglio.UsedRange.Rows.Count, 1).Address).Row

 

'

contarighe = 2

While contarighe <= quanterighe

      prezzopreve = foglio.Cells(contarighe, "j").Value

      prezzoddt = foglio.Cells(contarighe, "F").Value

      mesepreve = Month(foglio.Cells(contarighe, "r").Value)

      meseddt = Month(foglio.Cells(contarighe, "u").Value)

      If prezzopreve = prezzoddt Then   ' se il prezzo è uguale toglie la formattazione della cella

         foglio.Rows(contarighe).Interior.ColorIndex = xlNone

      Else

         If prezzoddt > prezzopreve Then ' se il prezzo del ddt è maggiore del preventivo

            If meseddt = mesepreve Then  ' verifica il mese del ddt e il mese preventivo corrispondano

               foglio.Rows(contarighe).Interior.ColorIndex = 46  ' evidenza la cella

            Else

                foglio.Rows(contarighe).Interior.ColorIndex = 8

            End If

         Else

            foglio.Rows(contarighe).Interior.ColorIndex = 6

         End If

      End If

      contarighe = contarighe + 1

Wend

'

End Sub

'

Nessun commento:

Posta un commento