Código: Selecionar todos
Option Explicit
Private TextoDigitado As String
Private Sub ListBox2_Click()
ActiveCell.Value = ListBox2.Value
Range("R8:T80").Interior.Color = RGB(255, 255, 255)
Range("R8:T80").Font.Color = RGB(0, 0, 0)
retorndaDadosCliente ListBox2
defineAreaImpressão ActiveSheet.Name
Unload Me
Range("R1").Activate
End Sub
Private Sub TextBox2_Change()
TextoDigitado = TextBox2.Text
Call PreencheLista
End Sub
Private Sub UserForm_Initialize()
Call PreencheLista
End Sub
Private Sub PreencheLista()
Dim ws As Worksheet
Dim i As Integer
Dim TextoCelula As String
Set ws = ThisWorkbook.Worksheets(2)
i = 2
ListBox2.Clear
With ws
While .Cells(i, 1).Value <> Empty
TextoCelula = .Cells(i, 1).Value
If UCase(Left(TextoCelula, Len(TextoDigitado))) = UCase(TextoDigitado) Then
ListBox2.AddItem .Cells(i, 1)
End If
i = i + 1
Wend
End With
End Sub
Function retorndaDadosCliente(ByVal nome As String)
Dim valorcliente
valorcliente = Application.WorksheetFunction.VLookup(nome, ThisWorkbook.Sheets("clientevalor").Range("A2:D10000"), 4, False)
With ThisWorkbook.Sheets("RelatórioSemanal")
.Activate
Dim ultimaLinha As Integer
ultimaLinha = .UsedRange.Rows.Count
Range("R8:T100").Select
Selection.ClearContents
Dim rangeRelatorio As Range
Dim produto As String
Dim DATA As Date
Dim VALOR As Double
Dim VALOR1 As Double
Dim VALOR2 As Double
Dim VALOR3 As Double
Dim VALOR4 As Double
Dim VALOR5 As Double
Dim VALOR6 As Double
Dim VALOR7 As Double
Dim VALOR8 As Double
Dim VALOR9 As Double
Dim VALOR10 As Double
Dim VALOR11 As Double
Dim VALOR12 As Double
Dim VALOR13 As Double
Dim VALOR14 As Double
Dim rLinha As Integer
rLinha = 8
Dim somaValores
somaValores = 0
Dim somaValores1
somaValores1 = 0
Dim somaValores2
somaValores2 = 0
Dim somaValores3
somaValores3 = 0
Dim somaValores4
somaValores4 = 0
Dim somaValores5
somaValores5 = 0
Dim somaValores6
somaValores6 = 0
Dim somaValores7
somaValores7 = 0
Dim somaValores8
somaValores8 = 0
Dim somaValores9
somaValores9 = 0
Dim somaValores10
somaValores10 = 0
Dim somaValores11
somaValores11 = 0
Dim somaValores12
somaValores12 = 0
Dim somaValores13
somaValores13 = 0
Dim somaValores14
somaValores14 = 0
Dim vLinha As Integer
For vLinha = 2 To ultimaLinha
Cells(vLinha, "A").Select
If Cells(vLinha, "A") = "" Then Exit For
If Cells(vLinha, "A") <> "" Then
If ActiveCell = nome Then
VALOR = ActiveCell.Offset(0, 1)
VALOR1 = ActiveCell.Offset(0, 2)
VALOR2 = ActiveCell.Offset(0, 3)
VALOR3 = ActiveCell.Offset(0, 4)
VALOR4 = ActiveCell.Offset(0, 5)
VALOR5 = ActiveCell.Offset(0, 6)
VALOR6 = ActiveCell.Offset(0, 7)
VALOR7 = ActiveCell.Offset(0, 8)
VALOR8 = ActiveCell.Offset(0, 9)
VALOR9 = ActiveCell.Offset(0, 10)
VALOR10 = ActiveCell.Offset(0, 11)
VALOR11 = ActiveCell.Offset(0, 12)
VALOR12 = ActiveCell.Offset(0, 13)
VALOR13 = ActiveCell.Offset(0, 14)
VALOR14 = ActiveCell.Offset(0, 15)
DATA = ActiveCell.Offset(0, 16)
Cells(rLinha, "T") = CDate(DATA)
Cells(rLinha, "S") = Format(VALOR, "###0.00")
Cells(rLinha, "R") = "F. ABATIDO"
somaValores = somaValores + VALOR
Cells(rLinha + 4, "S") = Format(VALOR1, "###0.00")
Cells(rLinha + 4, "R") = "F. VIVO"
Cells(rLinha + 4, "T") = CDate(DATA)
somaValores1 = somaValores1 + VALOR1
Cells(rLinha + 8, "S") = Format(VALOR2, "###0.00")
Cells(rLinha + 8, "R") = "COXA"
Cells(rLinha + 8, "T") = CDate(DATA)
somaValores2 = somaValores2 + VALOR2
Cells(rLinha + 12, "S") = Format(VALOR3, "###0.00")
Cells(rLinha + 12, "R") = "PEITO"
Cells(rLinha + 12, "T") = CDate(DATA)
somaValores3 = somaValores3 + VALOR3
Cells(rLinha + 16, "S") = Format(VALOR4, "###0.00")
Cells(rLinha + 16, "R") = "ASA"
Cells(rLinha + 16, "T") = CDate(DATA)
somaValores4 = somaValores4 + VALOR4
Cells(rLinha + 20, "S") = Format(VALOR5, "###0.00")
Cells(rLinha + 20, "R") = "CORAÇÃO"
Cells(rLinha + 20, "T") = CDate(DATA)
somaValores5 = somaValores5 + VALOR5
Cells(rLinha + 24, "S") = Format(VALOR6, "###0.00")
Cells(rLinha + 24, "R") = "PICADO"
Cells(rLinha + 24, "T") = CDate(DATA)
somaValores6 = somaValores6 + VALOR6
Cells(rLinha + 28, "S") = Format(VALOR7, "###0.00")
Cells(rLinha + 28, "R") = "MOELA"
Cells(rLinha + 28, "T") = CDate(DATA)
somaValores7 = somaValores7 + VALOR7
Cells(rLinha + 32, "S") = Format(VALOR8, "###0.00")
Cells(rLinha + 32, "R") = "FIGADO"
Cells(rLinha + 32, "T") = CDate(DATA)
somaValores8 = somaValores8 + VALOR8
Cells(rLinha + 36, "S") = Format(VALOR9, "###0.00")
Cells(rLinha + 36, "R") = "GALETO"
Cells(rLinha + 36, "T") = CDate(DATA)
somaValores9 = somaValores9 + VALOR9
Cells(rLinha + 40, "S") = Format(VALOR10, "###0.00")
Cells(rLinha + 40, "R") = "MIUDO"
Cells(rLinha + 40, "T") = CDate(DATA)
somaValores10 = somaValores10 + VALOR10
Cells(rLinha + 44, "S") = Format(VALOR11, "###0.00")
Cells(rLinha + 44, "R") = "FRENTE"
Cells(rLinha + 44, "T") = CDate(DATA)
somaValores11 = somaValores11 + VALOR11
Cells(rLinha + 48, "S") = Format(VALOR12, "###0.00")
Cells(rLinha + 48, "R") = "FILÉ"
Cells(rLinha + 48, "T") = CDate(DATA)
somaValores12 = somaValores12 + VALOR12
Cells(rLinha + 52, "S") = Format(VALOR13, "###0.00")
Cells(rLinha + 52, "R") = "BOBINA"
Cells(rLinha + 52, "T") = CDate(DATA)
somaValores13 = somaValores13 + VALOR13
Cells(rLinha + 56, "S") = Format(VALOR14, "###0.00")
Cells(rLinha + 56, "R") = "MATRIZ"
Cells(rLinha + 56, "T") = CDate(DATA)
somaValores14 = somaValores14 + VALOR14
rLinha = rLinha + 1
End If
End If
Next
Cells(rLinha, "T") = valorcliente
Cells(rLinha, "R") = "TOTAL (Kg):"
Cells(rLinha, "S") = Format(somaValores, "STANDARD")
Cells(rLinha + 1, "T") = Cells(rLinha, "S") * Cells(rLinha, "T")
Cells(rLinha + 4, "T") = 5.5
Cells(rLinha + 4, "R") = "TOTAL (Kg):"
Cells(rLinha + 4, "S") = Format(somaValores1, "STANDARD")
Cells(rLinha + 5, "T") = Cells(rLinha + 4, "S") * Cells(rLinha + 4, "T")
Cells(rLinha + 8, "T") = 5.7
Cells(rLinha + 8, "R") = "TOTAL (Kg):"
Cells(rLinha + 8, "S") = Format(somaValores2, "STANDARD")
Cells(rLinha + 9, "T") = Cells(rLinha + 8, "S") * Cells(rLinha + 8, "T")
Cells(rLinha + 12, "T") = 7.9
Cells(rLinha + 12, "R") = "TOTAL (Kg):"
Cells(rLinha + 12, "S") = Format(somaValores3, "STANDARD")
Cells(rLinha + 13, "T") = Cells(rLinha + 12, "S") * Cells(rLinha + 12, "T")
Cells(rLinha + 16, "T") = 8
Cells(rLinha + 16, "R") = "TOTAL (Kg):"
Cells(rLinha + 16, "S") = Format(somaValores4, "STANDARD")
Cells(rLinha + 17, "T") = Cells(rLinha + 16, "S") * Cells(rLinha + 16, "T")
Cells(rLinha + 20, "T") = 15
Cells(rLinha + 20, "R") = "TOTAL (Kg):"
Cells(rLinha + 20, "S") = Format(somaValores5, "STANDARD")
Cells(rLinha + 21, "T") = Cells(rLinha + 20, "S") * Cells(rLinha + 20, "T")
Cells(rLinha + 24, "T") = 3
Cells(rLinha + 24, "R") = "TOTAL (Kg):"
Cells(rLinha + 24, "S") = Format(somaValores6, "STANDARD")
Cells(rLinha + 25, "T") = Cells(rLinha + 24, "S") * Cells(rLinha + 24, "T")
Cells(rLinha + 28, "T") = 4
Cells(rLinha + 28, "R") = "TOTAL (Kg):"
Cells(rLinha + 28, "S") = Format(somaValores7, "STANDARD")
Cells(rLinha + 29, "T") = Cells(rLinha + 28, "S") * Cells(rLinha + 28, "T")
Cells(rLinha + 32, "T") = 3
Cells(rLinha + 32, "R") = "TOTAL (Kg):"
Cells(rLinha + 32, "S") = Format(somaValores8, "STANDARD")
Cells(rLinha + 33, "T") = Cells(rLinha + 32, "S") * Cells(rLinha + 32, "T")
Cells(rLinha + 36, "T") = 12
Cells(rLinha + 36, "R") = "TOTAL (Kg):"
Cells(rLinha + 36, "S") = Format(somaValores9, "STANDARD")
Cells(rLinha + 37, "T") = Cells(rLinha + 36, "S") * Cells(rLinha + 36, "T")
Cells(rLinha + 40, "T") = 1.5
Cells(rLinha + 40, "R") = "TOTAL (Kg):"
Cells(rLinha + 40, "S") = Format(somaValores10, "STANDARD")
Cells(rLinha + 41, "T") = Cells(rLinha + 40, "S") * Cells(rLinha + 40, "T")
Cells(rLinha + 44, "T") = 6.7
Cells(rLinha + 44, "R") = "TOTAL (Kg):"
Cells(rLinha + 44, "S") = Format(somaValores11, "STANDARD")
Cells(rLinha + 45, "T") = Cells(rLinha + 44, "S") * Cells(rLinha + 44, "T")
Cells(rLinha + 48, "T") = 12
Cells(rLinha + 48, "R") = "TOTAL (Kg):"
Cells(rLinha + 48, "S") = Format(somaValores12, "STANDARD")
Cells(rLinha + 49, "T") = Cells(rLinha + 48, "S") * Cells(rLinha + 48, "T")
Cells(rLinha + 52, "T") = 12
Cells(rLinha + 52, "R") = "TOTAL (Kg):"
Cells(rLinha + 52, "S") = Format(somaValores13, "STANDARD")
Cells(rLinha + 53, "T") = Cells(rLinha + 52, "S") * Cells(rLinha + 52, "T")
Cells(rLinha + 56, "T") = 6
Cells(rLinha + 56, "R") = "TOTAL (Kg):"
Cells(rLinha + 56, "S") = Format(somaValores14, "STANDARD")
Cells(rLinha + 57, "T") = Cells(rLinha + 56, "S") * Cells(rLinha + 56, "T")
End With
Cells(rLinha + 1, "S") = "TOTAL:"
Cells(rLinha + 1, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 1, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 5, "S") = "TOTAL:"
Cells(rLinha + 5, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 5, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 9, "S") = "TOTAL:"
Cells(rLinha + 9, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 9, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 13, "S") = "TOTAL:"
Cells(rLinha + 13, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 13, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 17, "S") = "TOTAL:"
Cells(rLinha + 17, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 17, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 21, "S") = "TOTAL:"
Cells(rLinha + 21, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 21, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 25, "S") = "TOTAL:"
Cells(rLinha + 25, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 25, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 29, "S") = "TOTAL:"
Cells(rLinha + 29, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 29, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 33, "S") = "TOTAL:"
Cells(rLinha + 33, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 33, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 37, "S") = "TOTAL:"
Cells(rLinha + 37, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 37, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 41, "S") = "TOTAL:"
Cells(rLinha + 41, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 41, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 45, "S") = "TOTAL:"
Cells(rLinha + 45, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 45, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 49, "S") = "TOTAL:"
Cells(rLinha + 49, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 49, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 53, "S") = "TOTAL:"
Cells(rLinha + 53, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 53, "T").Font.Color = RGB(255, 255, 255)
Cells(rLinha + 57, "S") = "TOTAL:"
Cells(rLinha + 57, "T").Interior.Color = RGB(0, 0, 0)
Cells(rLinha + 57, "T").Font.Color = RGB(255, 255, 255)
End Function
ATT.