Hallo an die Experten hier,
muss vorab sagen - dass ich mich leider nur mit Excel an sich auskenne - jedoch nicht mit den Codes in VBA.
brauche aber dringend Hilfe für die Erstellung einer Datenbank mithilfe VBA Codes.
Ich würde gerne eine Datenbank anlegen - in der:
Spalte "B" --> Wert von Textbox1 eingetragen wird --> Wenn Wert in Zelle "B2" steht --> dann trage Wert in neue Zelle "B3" ein. ( bis Zelle "B366")
Spalte "E" --> Wert von Textbox2 eingetragen wird --> Wenn Wert drin steht --> dann trage Wert in neue Zeile von Spalte 5 ein. ( bis Zelle "B366")
Spalte "H" --> usw.
Spalte "K" --> usw.
Spalte "N" --> usw.
Spalte "Q" --> usw.
Spalte "T" --> usw.
Spalte "W" --> usw.
Habe mir eine Maske mit "Userform" erstellt - Soweit so gut.
Aber mit der Codierung hapert es noch!!!
Habe schon alles mögliche versucht, was ich mir selber beibringen konnte - ohne Erfolg
Schicke euch hier mal meinen Code:
Option Explicit
Private Sub Button_übernehmen_Click()
Dim x As Integer
For x = 2 To 366
ThisWorkbook.Sheets("B2:B366").Cells(x, 2) = TextBox_GESAMT.Text
If ThisWorkbook.Sheets("B2:B366").Cells(x, 2) <> "" Then
Else: ThisWorkbook.Sheets("B2:B366").Cells(x + 1, 2) = TextBox_GESAMT.Value
ThisWorkbook.Sheets("E2:E366").Cells(x, 5) = TextBox_UniProfiRente.Text
If ThisWorkbook.Sheets("E2:E366").Cells(x, 5) <> "" Then
Else: ThisWorkbook.Sheets("E2:E366").Cells(x + 1, 5) = TextBox_UniProfiRente.Value
ThisWorkbook.Sheets("H2:H366").Cells(x, 8) = TextBox_UniFonds.Text
If ThisWorkbook.Sheets("H2:H366").Cells(x, 8) <> "" Then
Else: ThisWorkbook.Sheets("H2:H366").Cells(x + 1, 8) = TextBox_UniFonds.Value
ThisWorkbook.Sheets("K2:K366").Cells(x, 11) = TextBox_PrivatFonds.Text
If ThisWorkbook.Sheets("K2:K366").Cells(x, 11) <> "" Then
Else: ThisWorkbook.Sheets("K2:K366").Cells(x + 1, 11) = TextBox_PrivatFonds.Value
ThisWorkbook.Sheets("N2:N366").Cells(x, 14) = TextBox_UniRak.Text
If ThisWorkbook.Sheets("N2:N366").Cells(x, 14) <> "" Then
Else: ThisWorkbook.Sheets("N2:N366").Cells(x + 1, 14) = TextBox_UniRak.Value
ThisWorkbook.Sheets("Q2:Q366").Cells(x, 17) = TextBox_UniDividendenAss.Text
If ThisWorkbook.Sheets("Q2:Q366").Cells(x, 17) <> "" Then
Else: ThisWorkbook.Sheets("Q2:Q366").Cells(x + 1, 17) = TextBox_UniDividendenAss.Value
ThisWorkbook.Sheets("T2:T366").Cells(x, 20) = TextBox_UniFavorit.Text
If ThisWorkbook.Sheets("T2:T366").Cells(x, 20) <> "" Then
Else: ThisWorkbook.Sheets("T2:T366").Cells(x + 1, 20) = TextBox_UniFavorit.Value
ThisWorkbook.Sheets("W2:W366").Cells(x, 23) = TextBox_UniFonds2.Text
If ThisWorkbook.Sheets("W2:W366").Cells(x, 23) <> "" Then
Else: ThisWorkbook.Sheets("W2:W366").Cells(x + 1, 23) = TextBox_UniFonds2.Value
End If
Next x
End Sub
Was mache ich Falsch?
Vielen Dank vorab!!!
|