Boas,
Veja se é isto que deseja:
Alterações que fiz estão a verde:
Private Sub CommandButton1_Click()
If TextBox1.Value <> "" Then
If MsgBox("Aplicar alterações no registro selecionado?", vbQuestion + vbYesNo, "Atualizar informações") = vbYes Then
On Error GoTo erro
ListBox1.List(ListBox1.ListIndex, 0) = TextBox1.Text
With ThisWorkbook.Sheets("tipomaterial")
.Cells(ActiveCell.Row, "A") = TextBox1
End With
MsgBox "Alteração realizada com sucesso!", vbInformation, "Atualização de dados"
Unload Me
telalistagemtipodemateriais.Show
End If
End If
If TextBox1.Value = "" Then
If MsgBox("Aplicar alterações no registro selecionado?", vbQuestion + vbYesNo, "Atualizar informações") = vbYes Then
MsgBox "É necessário informar o novo nome", vbInformation, "Atualização de dados"
Unload Me
editartipodemateriais.Show
End If
End If
Sheets("MENU").Activate
Exit Sub
erro:
MsgBox "É necessário selecionar um item e digitar o novo nome" Sheets("MENU").Activate
End Sub
Editar listbox.zip