het bestand waar de regel in word opgeslagen komt tevoorschijn.

Status
Niet open voor verdere reacties.

markwat

Gebruiker
Lid geworden
11 mrt 2011
Berichten
301
wanneer ik de regel wil opslaan komt kortstondig het bestand op de voorgrond.
het sluit wel automatisch af maar ik wil het bestand eigenlijk geheel niet zien.

Code:
Private Sub ComboBox4_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim f As Range, Wb As Worksheet, msg As Long
msg = MsgBox("Ja is toevoegen, Nee is Verwijderen?", vbCritical + vbYesNoCancel)
Application.DisplayAlerts = False

If msg <> vbNo And msg <> vbYes Then
    Exit Sub
Else: End If

With Workbooks.Open("C:\Dropbox\documenten\Excel omschrijving.xlsm").Sheets("blad2")
  If msg = vbYes And ComboBox4.ListIndex = -1 Then
     .Cells(Rows.Count, 1).End(xlUp).Offset(1) = ComboBox4.Value
    .Range("A3:A" & .Cells(Rows.Count, 1).End(xlUp).Row).Sort .Range("A3")
ElseIf msg = vbNo Then
         Set f = .Columns(1).Find(ComboBox4.Value, , , 1)
         If Not f Is Nothing Then .Rows(f.Row).Delete
    End If
 .Parent.Close -1
 Application.DisplayAlerts = True
End With
End Sub
 
Zonder dat je een voorbeeld document hebt geplaatst, zou ik dit proberen:
Code:
Private Sub ComboBox4_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
    Dim f As Range, Wb As Worksheet, msg As Long
    msg = MsgBox("Ja is toevoegen, Nee is Verwijderen?", vbCritical + vbYesNoCancel)
    
    If msg = vbCancel Then Exit Sub
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    With Workbooks.Open("C:\Dropbox\documenten\Excel omschrijving.xlsm").Sheets("blad2")
        If msg = vbYes And ComboBox4.ListIndex = -1 Then
            .Cells(Rows.Count, 1).End(xlUp).Offset(1) = ComboBox4.Value
            .Range("A3:A" & .Cells(Rows.Count, 1).End(xlUp).Row).Sort .Range("A3")
        Else
             Set f = .Columns(1).Find(ComboBox4.Value, , , 1)
             If Not f Is Nothing Then .Rows(f.Row).Delete
        End If
        .Parent.Close -1
    End With
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub
 
Laatst bewerkt:
Status
Niet open voor verdere reacties.
Steun Ons

Nieuwste berichten

Terug
Bovenaan Onderaan