Live-Forum - Die aktuellen Beiträge
Anzeige
Archiv - Navigation
388to392
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
388to392
388to392
Aktuelles Verzeichnis
Verzeichnis Index
Verzeichnis Index
Übersicht Verzeichnisse
Inhaltsverzeichnis

Eingabe per UserForm in Tabelle

Eingabe per UserForm in Tabelle
27.02.2004 12:45:20
Ina
Hallo Forum,
einen schönen Tag wünsche ich in die Runde!
Mein Problem:
Mit diesem Code (freundlicherweise von Ramses zur Verfügung gestellt) wurden Werte bisher per UserForm1 in die Tabelle2 Bereich B8:Y107 geschrieben.
Nun sollen die Eingaben mit derselben UserForm1 aber in die Tabelle1 Bereich DD193:EA292 erfolgen.

Private Sub CommandButton1_KLICK()
Dim intIndex As Integer, bolausgefüllt As Boolean, lngleereZeile As Long
For intIndex = 1 To 5
If Controls("TextBox" & CStr(intIndex)) = "" Then
Call FehltWas
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
For intIndex = 1 To 7
If Controls("CheckBox" & CStr(intIndex)) = True Then bolausgefüllt = True: Exit For
Next
If Not bolausgefüllt Then
MsgBox "Angabe fehlt: Gültig am...   ", 48, "Hinweis :-)"
Exit Sub
End If
With Worksheets("TABELLE2")
lngleereZeile = .Cells(65536, 2).End(xlUp).Row + 1
If lngleereZeile < 8 Then lngleereZeile = 8
For intIndex = 1 To 5
.Cells(lngleereZeile, intIndex + 1) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
For intIndex = 1 To 7
.Cells(lngleereZeile, intIndex + 6) = IIf(Controls("CheckBox" & CStr(intIndex)), "X", "")
Controls("CheckBox" & CStr(intIndex)) = False
Next
For intIndex = 6 To 17
.Cells(lngleereZeile, intIndex + 8) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
End With
TextBox1.SetFocus
If lngleereZeile = 107 Then
MsgBox "Die Tabelle ist voll." & vbCrLf & "Die Eingabe wird abgebrochen.", 48, "Hinweis :-)"
Unload Me
End If
End Sub

Ich habe mein Glück versucht, bekomme aber immer nur eine Fehlermeldung...
Daher meine Bitte: Wer kann den Code für einen VBA-Laien umschreiben??
Grüsse, Ina

11
Beiträge zum Forumthread
Beiträge zu diesem Forumthread

Betreff
Datum
Anwender
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 13:04:58
Ramses
Hallo
weiss zwar nicht mehr wann ich das gemacht habe, trotzdem danke :-)
Dies wäre der neue Code
Wenn ich das richtig verstanden habe, sollte es funktionieren

Private Sub CommandButton1_KLICK()
Dim intIndex As Integer, bolausgefüllt As Boolean, lngleereZeile As Long
For intIndex = 1 To 5
If Controls("TextBox" & CStr(intIndex)) = "" Then
Call FehltWas
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
For intIndex = 1 To 7
If Controls("CheckBox" & CStr(intIndex)) = True Then bolausgefüllt = True: Exit For
Next
If Not bolausgefüllt Then
MsgBox "Angabe fehlt: Gültig am...   ", 48, "Hinweis :-)"
Exit Sub
End If
With Worksheets("Tabelle1")
lngleereZeile = .Cells(65536, 108).End(xlUp).Row + 1
If lngleereZeile < 193 Then lngleereZeile = 193
For intIndex = 1 To 5
.Cells(lngleereZeile, intIndex + 1) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
For intIndex = 1 To 7
.Cells(lngleereZeile, intIndex + 6) = IIf(Controls("CheckBox" & CStr(intIndex)), "X", "")
Controls("CheckBox" & CStr(intIndex)) = False
Next
For intIndex = 6 To 17
.Cells(lngleereZeile, intIndex + 8) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
End With
TextBox1.SetFocus
If lngleereZeile = 292 Then
MsgBox "Die Tabelle ist voll." & vbCrLf & "Die Eingabe wird abgebrochen.", 48, "Hinweis :-)"
Unload Me
End If
End Sub


Gruss Rainer
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 14:52:20
Ina
Hallo Rainer,
kann es sein, das da irgend etwas nicht ganz stimmt?
Die Daten werden in B193 eingefügt, statt in DD193 bzw. die nächste leere Zelle. :-(
Kannst Du noch einmal helfen?
Gruss, Ina
AW: Eingabe per UserForm in Tabelle
27.02.2004 15:03:34
Ramses
Hallo
du hast recht :-)
Das habe ich übersehen
For intIndex = 1 To 5
.Cells(lngleereZeile, intIndex + 107) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
For intIndex = 1 To 7
.Cells(lngleereZeile, intIndex + 112) = IIf(Controls("CheckBox" & CStr(intIndex)), "X", "")
Controls("CheckBox" & CStr(intIndex)) = False
Next
For intIndex = 6 To 17
'114 könnte auch 120 heissen.
'bitte ausprobieren, weil ich deine Tabelle nicht kenne

.Cells(lngleereZeile, intIndex + 114) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next

Gruss Rainer
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 15:19:26
Ina
Hallo Rainer,
noch einmal Danke für Deine Mühe...
Jetzt wird in die richtige Spalte geschrieben, aber statt in DD193 (bzw. die nächste leere Zeile) wird in DD302 angefangen und in der nächsten leeren Zeile weitergeschrieben.
Wo liegt der Fehler?
Kannst Du noch einmal helfen??
Grüsse, Ina
AW: Eingabe per UserForm in Tabelle
27.02.2004 15:29:37
Ramses
Hallo
dann wird es kritisch, denn dann stehen schon Daten in der Spalte.
lngleereZeile = .Cells(65536, 108).End(xlUp).Row + 1
sucht die erste leere freie Zelle in Spalte DD. Wenn dort schon Daten stehen funktioniert das nicht.
Ändere mal
If lngleereZeile = 292 Then
in
If lngleereZeile > 292 Then
dann merkst du gleich wo der Fehler liegt.
Das von hier aus zu lösen wird schwierig werden
gruss Rainer
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 15:51:20
Ina
Hallo Rainer,
stimmt! Da waren schon Daten in der Spalte!
Habe die Daten entfernt und jetzt klappt das BESTENS! DANKE!
Darf ich noch ein Problem ansprechen?!
Ich möchte Werte per UserForm1 aus der Tabelle5 auslesen, ohne die aktuelle Tabelle (Tabelle1) zu verlassen.
Wechsele ich in die Tabelle5 und rufe von dort die UserForm1 auf, werden, nachdem ich mein Suchkriterium in die TextBox1 eingegeben habe und den CommandButton2 angeklickt habe, alle Werte korrekt angezeigt.
Rufe ich aber die UserForm1 aus der Tabelle1 auf, werden falsche Werte angezeigt.
Dieser Code stammt auch von Dir, kannst Du daran entsprechende Änderungen vornehmen?

Private Sub CommandButton2_Click()
Dim myRange As Range, intIndex As Integer
If Trim$(TextBox1) <> "" Then
With Worksheets("Tabelle5").Range("B8:B107")
Set myRange = .Find(What:=Trim$(TextBox1), LookIn:=xlValues, LookAt:=xlWhole)
If Not myRange Is Nothing Then
For intIndex = 2 To 5
'Controls("TextBox" & CStr(intIndex)) = Cells(myRange.Row, intIndex + 1)
Controls("TextBox" & CStr(intIndex)) = Format(Cells(myRange.Row, intIndex + 1), "HH:MM")
Next
For intIndex = 1 To 7
If Cells(myRange.Row, intIndex + 6) = "X" Then Controls("CheckBox" & CStr(intIndex)) = True
Next
For intIndex = 6 To 17
'Controls("TextBox" & CStr(intIndex)) = Cells(myRange.Row, intIndex + 8)
Controls("TextBox" & CStr(intIndex)) = Format(Cells(myRange.Row, intIndex + 8), "HH:MM")
Next
Set myRange = Nothing
Else
MsgBox "Kein Eintrag vorhanden.", 64, "Information"
End If
CommandButton2.Caption = "ABBRECHEN"
End With
End If
Else
Unload Me
End Sub

Vielen Dank schon mal vorab!
Grüsse, Ina
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 16:56:11
Ramses
Hallo
der Code ist definitiv nicht von mir :-)
Ich arbeite nicht mit Variablenzeichen wie "Trim$"
Anyway:
Probier mal

Private Sub CommandButton2_Click()
Dim myRange As Range, intIndex As Integer
If Trim$(TextBox1) <> "" Then
With Worksheets("Tabelle5").Range("B8:B107")
Set myRange = .Find(What:=Trim$(TextBox1), LookIn:=xlValues, LookAt:=xlWhole)
If Not myRange Is Nothing Then
For intIndex = 2 To 5
Controls("TextBox" & CStr(intIndex)) = Format(Worksheets("Tabelle5").Cells(myRange.Row, intIndex + 1), "HH:MM")
Next
For intIndex = 1 To 7
If Worksheets("Tabelle5").Cells(myRange.Row, intIndex + 6) = "X" Then Controls("CheckBox" & CStr(intIndex)) = True
Next
For intIndex = 6 To 17
Controls("TextBox" & CStr(intIndex)) = Format(Worksheets("Tabelle5").Cells(myRange.Row, intIndex + 8), "HH:MM")
Next
Set myRange = Nothing
Else
MsgBox "Kein Eintrag vorhanden.", 64, "Information"
End If
CommandButton2.Caption = "ABBRECHEN"
End With
End If
Else
Unload Me
End Sub

Gruss Rainer
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 17:02:23
Ina
Hallo Rainer,
dann habe ich mich wohl vertan und der Code kommt von Sepp... Sorry!
Trotzdem... Mit Deiner Änderung klappt das BESTENS!
Vielen, vielen Dank!!
Grüsse, Ina
Merci :-) Geschlossen o.T.
28.02.2004 01:07:16
Ramses
...
AW: Eingabe per UserForm in Tabelle
27.02.2004 13:10:35
xXx
Hallo,
so sollte es gehen:

Private Sub CommandButton1_KLICK()
Dim intIndex As Integer, bolausgefüllt As Boolean, lngleereZeile As Long
For intIndex = 1 To 5
If Controls("TextBox" & CStr(intIndex)) = "" Then
Call FehltWas
Controls("TextBox" & CStr(intIndex)).SetFocus
Exit Sub
End If
Next
For intIndex = 1 To 7
If Controls("CheckBox" & CStr(intIndex)) = True Then bolausgefüllt = True: Exit For
Next
If Not bolausgefüllt Then
MsgBox "Angabe fehlt: Gültig am...   ", 48, "Hinweis :-)"
Exit Sub
End If
With Worksheets("TABELLE1")
lngleereZeile = .Cells(65536, 108).End(xlUp).Row + 1
If lngleereZeile < 193 Then lngleereZeile = 193
For intIndex = 1 To 5
.Cells(lngleereZeile, intIndex + 107) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
For intIndex = 1 To 7
.Cells(lngleereZeile, intIndex + 112) = IIf(Controls("CheckBox" & CStr(intIndex)), "X", "")
Controls("CheckBox" & CStr(intIndex)) = False
Next
For intIndex = 6 To 17
.Cells(lngleereZeile, intIndex + 114) = Controls("TextBox" & CStr(intIndex))
Controls("TextBox" & CStr(intIndex)) = ""
Next
End With
TextBox1.SetFocus
If lngleereZeile = 292 Then
MsgBox "Die Tabelle ist voll." & vbCrLf & "Die Eingabe wird abgebrochen.", 48, "Hinweis :-)"
Unload Me
End If
End Sub

Gruß aus'm Pott
Udo
http://www.excelerator.de

P.S. Das Forum lebt auch von den Rückmeldungen an die Antworter!
Anzeige
AW: Eingabe per UserForm in Tabelle
27.02.2004 14:50:45
Ina
Hallo Udo,
kann es sein, das da irgend etwas nicht ganz stimmt?
Die Daten werden in B193 eingefügt, statt in DD193. :-(
Kannst Du noch einmal helfen?
Gruss, Ina

301 Forumthreads zu ähnlichen Themen

Anzeige
Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige

Beliebteste Forumthreads (12 Monate)

Anzeige
Anzeige
Anzeige