Hey Excel Profis,
folgende Herausforderung: Ich habe ein Formular mit TextBoxen erstellt. Allerdings ist nicht immer ein Eintrag in einer beliebigen TextBox erforderlich. Bei der Übernahme in die Exceltabelle meckert er dann rum, wenn eine oder mehrere TextBoxen leer sind. Wie und an welcher Stelle schreibe ich den Code so um, dass leere TextBoxen akzeptiert werden?
Besten Dank schon mal im Voraus ;)
Stefan
folgende Herausforderung: Ich habe ein Formular mit TextBoxen erstellt. Allerdings ist nicht immer ein Eintrag in einer beliebigen TextBox erforderlich. Bei der Übernahme in die Exceltabelle meckert er dann rum, wenn eine oder mehrere TextBoxen leer sind. Wie und an welcher Stelle schreibe ich den Code so um, dass leere TextBoxen akzeptiert werden?
Besten Dank schon mal im Voraus ;)
Stefan
Code:
Option Explicit
Private Sub CommandButton1_Fertig_Click()
'Erste freie Zeile ausfindig machen
Dim last As Integer
last = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1
'Projektnummer
Cells(last, 1).Value = TextBox_Projektnr.Value * 1
'Straße
Cells(last, 2).Value = TextBox_Straße
'Hs.Nr.
Cells(last, 3).Value = TextBox_Hausnummer.Value * 1
'PLZ
Cells(last, 4).Value = TextBox_PLZ.Value * 1
'Ort/Bezirk
Cells(last, 5).Value = TextBox_OrtBezirk
'WE
Cells(last, 6).Value = TextBox_WE1
Cells(last, 8).Value = TextBox_WE2
Cells(last, 10).Value = TextBox_WE3
Cells(last, 12).Value = TextBox_WE4
'TD
Cells(last, 7).Value = TextBox_TD1.Value * 1
Cells(last, 9).Value = TextBox_TD2.Value * 1
Cells(last, 11).Value = TextBox_TD3.Value * 1
Cells(last, 13).Value = TextBox_TD4.Value * 1
End Sub
Private Sub CommandButton2_Schließen_Click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
'Projektnummer
TextBox_Projektnr = ""
'Straße
TextBox_Straße = ""
'Hs.Nr.
TextBox_Hausnummer = ""
'PLZ
TextBox_PLZ = ""
'Ort/Bezirk
TextBox_OrtBezirk = ""
'WE
TextBox_WE1 = ""
TextBox_WE2 = ""
TextBox_WE3 = ""
TextBox_WE4 = ""
'TD
TextBox_TD1 = ""
TextBox_TD2 = ""
TextBox_TD3 = ""
TextBox_TD4 = ""
End Sub
Interpunktion und Orthographie dieses Textes sind frei erfunden.
Eine Übereinstimmung mit aktuellen oder ehemaligen Regeln wäre rein zufällig und ist nicht beabsichtigt.
Grüße, StefanB