debuggen
04.02.2008 14:46:00
ganz
ich habe ein USERFORM indem ich name und adresse eingebe,
über den übernehmenbutton soll die adresse in der tabelle eingefügt werden und sortiert werden.
in spalte a steht die adresse komplett drin(mit =b2+c2+d2) .
immer wenn ich eine adresse einpflege kommt nun Debuggen und folgender text aus dem unstenstehenden code wird markiert:
Range("B2:E" & lLetzte).Sort _
Key1:=Range("B2"), Order1:=xlAscending, _
Key2:=Range("D2"), Order2:=xlAscending, _
Key3:=Range("C2"), Order3:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Kann mir jemand helfen wie ich es richtig machen kann damit dieses debuggen nicht wieder kommt?
Vielen Dank im voraus
ralf
Option Explicit
'
' übernehmen
'
Private Sub CommandButton1_Click()
Dim lLetzte As Long
If TextBox1.Value = "" Then
MsgBox "Die TextBox1 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox1.SetFocus
Exit Sub
End If
If TextBox2.Value = "" Then
MsgBox "Die TextBox2 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox2.SetFocus
Exit Sub
End If
If TextBox3.Value = "" Then
MsgBox "Die TextBox3 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox3.SetFocus
Exit Sub
End If
If TextBox4.Value = "" Then
MsgBox "Die TextBox4 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox4.SetFocus
Exit Sub
End If
Application.ScreenUpdating = False
With Worksheets("Mandanten")
lLetzte = IIf(.Range("A65536") "", 65536, .Range("A65536").End(xlUp).Row) + 1
If lLetzte
'
' Eingabeinhalte löschen
'
Private Sub CommandButton2_Click()
Dim iIndex As Integer
For iIndex = 1 To 4
With Controls("TextBox" & iIndex)
.Value = ""
End With
Next iIndex
CommandButton4.Enabled = False ' den Änder-Button sperren
End Sub
'
' ändern
'
Private Sub CommandButton4_Click()
Dim lLetzte As Long
If TextBox1.Value = "" Then
MsgBox "Die TextBox1 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox1.SetFocus
Exit Sub
End If
If TextBox2.Value = "" Then
MsgBox "Die TextBox2 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox2.SetFocus
Exit Sub
End If
If TextBox3.Value = "" Then
MsgBox "Die TextBox3 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox3.SetFocus
Exit Sub
End If
If TextBox4.Value = "" Then
MsgBox "Die TextBox4 muss eine Eingabe enthalten!", _
48, " Hinweis für " & Application.UserName
TextBox4.SetFocus
Exit Sub
End If
Application.ScreenUpdating = False
With Worksheets("Mandanten")
.Range("A" & FundZeile).Value = Trim(WorksheetFunction.Proper(TextBox4.Value))
.Range("B" & FundZeile).Value = Trim(WorksheetFunction.Proper(TextBox1.Value))
.Range("C" & FundZeile).Value = Trim(WorksheetFunction.Proper(TextBox2.Value))
.Range("D" & FundZeile).Value = Trim(TextBox3.Value) & " " & _
Trim(WorksheetFunction.Proper(TextBox4.Value))
With .Range("B" & FundZeile & ":D" & FundZeile)
.Font.Name = "Arial"
.Font.Size = 12
End With
With .Range("A" & FundZeile & ":G" & FundZeile)
.Interior.ColorIndex = 9
.Font.ColorIndex = 2
End With
lLetzte = IIf(.Range("A65536") "", 65536, .Range("A65536").End(xlUp).Row) + 1
If lLetzte Range("B2:E" & lLetzte).Sort _
Key1:=Range("B2"), Order1:=xlAscending, _
Key2:=Range("D2"), Order2:=xlAscending, _
Key3:=Range("C2"), Order3:=xlAscending, _
Key4:=Range("E2"), Order4:=xlAscending, _
Header:=xlNo, _
OrderCustom:=1, _
MatchCase:=False, _
Orientation:=xlTopToBottom
Columns("B:E").EntireColumn.AutoFit
End With
Application.ScreenUpdating = True
CommandButton4.Enabled = False ' den Änder-Button sperren
End Sub
Private Sub CommandButton6_Click()
Unload UserForm10
UserForm4.Show
End Sub
'
' schließen
'
Private Sub Image1_Click()
Unload UserForm10
Call Mandantenpflege_anzeigen
End Sub
Private Sub UserForm_Initialize()
'Userform wird auf die Größe von Excel gezoomt, wobei die
'die Controls entsprechend gezoomt und zentriert werden.
'Uwe Küstner 20070622
Dim Faktor As Single
Dim X As Single, Y As Single
Dim sngL As Single, sngO As Single, sngR As Single, sngU As Single
Dim oC As MSForms.Control
Faktor = Application.Height / (Me.Height - 20)
If Faktor 4 Then Faktor = 4
Me.Width = Application.Width
Me.Height = Application.Height
sngL = Me.Width
sngO = Me.Height
For Each oC In Me.Controls
sngL = Application.WorksheetFunction.Min(sngL, oC.Left)
sngO = Application.WorksheetFunction.Min(sngO, oC.Top)
sngR = Application.WorksheetFunction.Max(sngR, oC.Left + oC.Width)
sngU = Application.WorksheetFunction.Max(sngU, oC.Top + oC.Height)
Next oC
X = (Me.Width - (sngR * Faktor) - (sngL * Faktor)) / 2 / Faktor
Y = (Me.Height - (sngO * Faktor) - (sngU * Faktor) - 20) / 2 / Faktor
Me.Controls.Move X, Y
Me.Zoom = Faktor * 100
End Sub