You are on page 1of 2

UserForm2 - 1

Private Sub CommandButton1_Click()

'turn screen updating off - makes program faster


Application.ScreenUpdating = False

If ComboBox1.Text = "Entregue SP" Then ' insere (sp) no registo e insere obs
'Cells(ActiveCell.Row, 4) = "(SP) " &replace( TextBox4.Text, "[";
Cells(ActiveCell.Row, 6) = Replace(TextBox4.Text, "]", "](SP)")
Cells(ActiveCell.Row, 7) = TextBox5.Text
End If

If ComboBox1.Text <> "" Then

' copia registo para historico


Call copy2hist(Cells(ActiveCell.Row, 1), 1) ' nome fich
Call copy2hist(Cells(ActiveCell.Row, 2), 2) ' cod pi
Call copy2hist(Cells(ActiveCell.Row, 3), 3) ' tecnico
Call copy2hist(Cells(ActiveCell.Row, 4), 4) ' data rot
Call copy2hist(Cells(ActiveCell.Row, 5), 5) ' tipo rot
Call copy2hist(Cells(ActiveCell.Row, 6), 6) 'anomalia
Call copy2hist(ComboBox1.Text, 7) ' estado
Call copy2hist(UserName(), 8) ' user
Call copy2hist(Year(Date) & "-" & Month(Date) & "-" & Day(Date), 9) ' data
Call copy2hist(TextBox5.Text, 10) ' obs

End If

If ComboBox1.Text <> "Entregue SP" Then ' apaga registo dos pendentes desde que nao entregues ao SP
Range("A" & CStr(ActiveCell.Row) & ":" & "G" & CStr(ActiveCell.Row)).Select

Selection.Delete Shift:=xlUp
End If

'turn screen updating back on


Application.ScreenUpdating = True

PendSht.Cells(1, 7) = "Pendentes actualizado em: " & Actual_Date

'MsgBox "A" & CStr(ActiveCell.Row) & ":" & "D" & CStr(ActiveCell.Row)
Unload Me
End Sub

Private Sub TextBox1_Change()


If TextBox1.Text = "ord41" Then
CommandButton1.Enabled = True
End If
End Sub

Private Sub UserForm_Initialize()

Actual_Date = Format(Now(), "yyyy-mm-dd")

With ComboBox1
.Clear
'.AddItem "Pendente"
.AddItem "Reparado MEO"
.AddItem "Entregue SP"
.AddItem "Reparado SP"
.AddItem "Equip.Desactivado"
.AddItem "Reparado na MPI"
.AddItem "Outro"
'.AddItem "Desactualizado"

End With

CommandButton1.Enabled = False
UserForm2 - 2

'Let linha = ActiveCell.Row


TextBox3.Text = Cells(ActiveCell.Row, 2) 'Cod PI

TextBox2.Text = Cells(ActiveCell.Row, 4) 'Data Rotina

TextBox4.Text = Cells(ActiveCell.Row, 6) 'Anomalia

TextBox5.Text = Cells(ActiveCell.Row, 7) 'Observaçoes

End Sub

You might also like