Hello everyone,
I have a code which helps to edit/add new data into a table.
I'd like that one of the cells values would arrive from multiple TextBoxes and the code would be available for the whole column.
The code i have :
The code i need to enter (something like):
I tried, but couldn't figure it out.
Any help or tips are really appreciated
Cross-posted here
I have a code which helps to edit/add new data into a table.
I'd like that one of the cells values would arrive from multiple TextBoxes and the code would be available for the whole column.
The code i have :
VBA Code:
Sub EditAdd()
Dim id As Integer, i As Integer, j As Integer, flag As Boolean
Dim emptyRow As Long
If UserForm1.TextBox1.Value <> "" Then
flag = False
i = 0
id = UserForm1.TextBox1.Value
emptyRow = WorksheetFunction.CountA(Range("A:A")) + 1
Do While Cells(i + 1, 1).Value <> ""
If Cells(i + 1, 1).Value = id Then
flag = True
For j = 2 To 10
Cells(i + 1, j).Value = UserForm1.Controls("TextBox" & j).Value
i = i + 1
Loop
If flag = False Then
For j = 1 To 10
Cells(emptyRow, j).Value = UserForm1.Controls("TextBox" & j).Value
Next j
End If
End If
End Sub
VBA Code:
If j = 9 Then Cells(i, j).Value =
UserForm1.Controls(TextBox12).Value & vbCrLf &
UserForm1.Controls(TextBox13).Value & vbCrLf &
UserForm1.Controls(TextBox14).Value & vbCrLf &
UserForm1.Controls(TextBox15).Value & vbCrLf &
UserForm1.Controls(TextBox16).Value
or if Cells.column = 9 then
or if cells(i, j).column = 9 then.
End If
Any help or tips are really appreciated
Cross-posted here