Boa Tarde
Teria como simplificar a macro abaixo pois vou tera mais linhas iguais.
Teria como colocar um loop ai ?
mudara: Pro1.Value , Label_Pro1, Label_Pro1A ....
Private Sub Pro1_Enter()
Sheets("Estoque").Activate
Dim intervalo As Range
Dim codigo As Integer
Set intervalo = Plan19.Range("B6:W605")
codigo = Pro1.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro1.Caption = Pesquisa
Label_Pro1A.Caption = Pesquisa1
codigo = Pro2.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro2.Caption = Pesquisa
Label_Pro2A.Caption = Pesquisa1
codigo = Pro3.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro3.Caption = Pesquisa
Label_Pro3A.Caption = Pesquisa1
codigo = Pro4.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro4.Caption = Pesquisa
Label_Pro4A.Caption = Pesquisa1
codigo = Pro5.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro5.Caption = Pesquisa
Label_Pro5A.Caption = Pesquisa1
codigo = Pro6.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro6.Caption = Pesquisa
Label_Pro6A.Caption = Pesquisa1
codigo = Pro7.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro7.Caption = Pesquisa
Label_Pro7A.Caption = Pesquisa1
codigo = Pro8.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro8.Caption = Pesquisa
Label_Pro8A.Caption = Pesquisa1
codigo = Pro8.Value
Pesquisa = Application.WorksheetFunction.VLookup(codigo, intervalo, 4, False)
Pesquisa1 = Application.WorksheetFunction.VLookup(codigo, intervalo, 6, False)
Label_Pro8.Caption = Pesquisa
Label_Pro8A.Caption = Pesquisa1
End Sub
Postado : 27/01/2017 11:21 am