Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
900to904
Aktuelles Verzeichnis
Verzeichnis Index
Übersicht Verzeichnisse
Vorheriger Thread
Rückwärts Blättern
Nächster Thread
Vorwärts blättern
Anzeige
HERBERS
Excel-Forum (Archiv)
20+ Jahre Excel-Kompetenz: Von Anwendern, für Anwender
900to904
900to904
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Laufzeitfehler 1004 abfangen
05.09.2007 10:54:00
Kai
Hallo
Ich zähle mit VBA die Anzahl der nicht leeren Zellen in 2 Bereichen.
xalt = Sheets(bez).Range("b9:b1000").SpecialCells(xlCellTypeConstants).Count
xneu = Sheets(bez).Range("c9:c1000").SpecialCells(xlCellTypeConstants).Count
Dabei kann es vorkommen, das ein Bereich komplett leer ist. Ich bekomme dann die Meldung:
Laufzeitfehler '1004': Keine Zellen gefunden.
Ich habe folgendes versucht:
On Error gogo weiter
xalt = Sheets(bez).Range("b9:b1000").SpecialCells(xlCellTypeConstants).Count
xneu = Sheets(bez).Range("c9:c1000").SpecialCells(xlCellTypeConstants).Count
weiter:
on Error goto 0
Das hilft aber leider auch nicht.
Wie kann ich den Fehler abfangen?
Grüße
Kai

7
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Laufzeitfehler 1004 abfangen
05.09.2007 11:00:30
Chaos
Servus,
probiers mal mit On Error Resume Next.
Gruß
Chaos

AW: Laufzeitfehler 1004 abfangen
05.09.2007 11:18:00
Kai
Hallo
Es funtioniert mit
On Error Resume Next
neue_user = 0
Xalt = 0
xneu = 0
Xalt = Sheets(bez).Range("b9:b1000").SpecialCells(xlCellTypeConstants).Count 'user vormonat
xneu = Sheets(bez).Range("c9:c1000").SpecialCells(xlCellTypeConstants).Count ''user neuer monat
If Xalt = 0 Or xneu = 0 Then Xalt = xneu
Danke
Kai

AW: Laufzeitfehler 1004 abfangen
05.09.2007 11:21:00
ganz
hallo,
da habe ich auch eine frage zu:
bei mir kommt der laufzeitfehler 1004: Um diese Aktion auszuführen müssen alle verbundenen Zellen die gleiche größe haben.
wie kann ich, wenn vorhanden die verbundenen zellen leicht und schnell finden.
die fett markierte stelle im code ist beim debuggen gelb markiert(siehe unten)
Über antworten würde ich mich sehr freuen.
gruß
ralf

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   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
Columns("A:E").EntireColumn.AutoFit
End With
Application.ScreenUpdating = True
CommandButton4.Enabled = False  ' den Änder-Button sperren
End Sub


Anzeige
AW: doppelt
05.09.2007 11:42:21
ganz
Hallo,
ja die Frage war schonmal aber ich habe das Problem immer noch.

AW: doppelt
05.09.2007 11:53:27
Renee
Hi Ralf,
Darum ist ja der andere Thread noch offen!
Du hast aber nie auf meine Antwort reagiert. Die Tabelle die Du hochgeladen hast, enthält Dein beschriebenes Problem nicht. Sie enthält nicht mal 1 Zeile Code!
Greetz Renee

Anzeige
AW: doppelt
05.09.2007 12:06:19
ganz
Hall Renee,
ich kenne mich nicht so aus.
dieser code steht im userform
Kannst du damit was anfangen?
Gruß
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 



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_Activate()
CommandButton4.Enabled = False  ' den Änder-Button sperren
Me.Top = 0
Me.Left = 0
Me.Width = Application.Width
Me.Height = Application.Height
End Sub


Anzeige

33 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige
Anzeige

Links zu Excel-Dialogen

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige