wenn im nachfolgenden VBA-Code die InputBox leer ist und auf
die Taste "Abbrechen" geklickt wird soll das Makro abbrechen.
Ich habe mit: If dInput = "" Then Exit Sub probiert, funktioniert nicht.
Sub FindenEinfuegen()
Dim wks(1 To 2) As Worksheet
Dim rng As Range
Dim dInput As Double
Dim iWks As Integer
Dim sRng As String
Worksheets("Deckblatt").Select
Application.ScreenUpdating = False
Set wks(1) = Worksheets("Tabelle1")
Set wks(2) = Worksheets("Tabelle2")
dInput = Application.InputBox( _
prompt:="Geben Sie eine Variante ein:", _
Title:="Versuchsglieder", _
Type:=1)
If dInput = "" Then Exit Sub
For iWks = 1 To 2
Set rng = wks(iWks).Cells.Find(dInput, lookat:=xlWhole, LookIn:=xlValues)
If Not rng Is Nothing Then
sRng = rng.Address
rng.Offset(1, 0).EntireRow.Insert
Do
Set rng = wks(iWks).Cells.FindNext(rng)
If rng.Address <> sRng Then
rng.Offset(1, 0).EntireRow.Insert
Else
Exit Do
End If
Loop
End If
Next iWks
End Sub
Kann mir jemand helfen?
Viele Dank.
Grüße