View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Eddie_SP[_2_] Eddie_SP[_2_] is offline
external usenet poster
 
Posts: 47
Default If ListBox = "" then

Hi OssieMac and Dave...

Here is the code:

Private Sub CommandButton1_Click()
Dim ComboRef As String
Dim i As Integer
Dim c As Integer
Dim Pedido As String
Dim Aba As String
Dim Item As String

ComboRef = Me.ComboBox1.Value
i = 6

If ComboRef = "" Then
MsgBox ("Selecione o Fornecedor.")
Me.ComboBox1.SetFocus
Exit Sub
End If

If Me.TextBox1.Value = "" Then
MsgBox ("Insira a peça que deseja buscar.")
Me.TextBox1.SetFocus
Exit Sub
End If

Me.ListBox1.Clear

With Me.ListBox1
.ColumnCount = 3
.ColumnWidths = "60;30;210"

Worksheets(4).Activate
While (ActiveSheet.Cells(i, 1) < 0)
i = i + 1
Windows("Matriz.xls").Activate
Worksheets(4).Activate
If Cells(i, 2).Text = ComboRef And Cells(i, 34).Text =
"PENDENTE" Then


Item = UCase(Trim(Me.TextBox1.Text))

Workbooks.Open ("\\brfile100vm\edivando
souza\Importação\Importação - Cads\" & ComboRef & ".xls")
Windows("Matriz.xls").Activate
Aba = Worksheets("Pedidos").Cells(i, 1).Text
Windows(ComboRef & ".xls").Activate
Worksheets(Aba).Activate

c = 1

While (ActiveSheet.Cells(c, 1) < 0)
c = c + 1
If Cells(c, 5).Value = Item Then
.AddItem Aba
.List(.ListCount - 1, 1) = Cells(c, 4).Text
.List(.ListCount - 1, 2) = Cells(c, 8).Text
End If
Wend
End If
Wend

i = 31
c = 1
Windows("Matriz.xls").Activate
Worksheets(5).Activate
While (ActiveSheet.Cells(i, 1) < 0)
i = i + 1
Windows("Matriz.xls").Activate
Worksheets(5).Activate
If Cells(i, 2).Text = ComboRef And Cells(i, 34).Text =
"PENDENTE" Then


Item = UCase(Trim(Me.TextBox1.Text))

Workbooks.Open ("\\brfile100vm\edivando
souza\Importação\Importação - Cads\" & ComboRef & ".xls")
Windows("Matriz.xls").Activate
Aba = Worksheets("MarÃ*timos").Cells(i, 1).Text
Windows(ComboRef & ".xls").Activate
Worksheets(Aba).Activate

c = 1

While (ActiveSheet.Cells(c, 1) < 0)
c = c + 1
If Cells(c, 5).Value = Item Then
.AddItem Aba
.List(.ListCount - 1, 1) = Cells(c, 4).Text
.List(.ListCount - 1, 2) = Cells(c, 8).Text
End If
Wend
End If
Wend
End With

If ActiveWorkbook.Name < ThisWorkbook.Name Then
ActiveWorkbook.Close False
End If

End Sub

This code is used to search for items which are oming in importations.
The user selects the Company (Exporter) and types the item #.
At the end the item is shown on ListBox if it is being imported.
If it is not being imported, any message appears...

Can you help me on that?

Best Regards !!!