Hi Everyone,
I'm sure this has been asked before, but I can't seem to find the answer.
I have a userform that is currently submitting data to the "Database" tab by userform, I want to be able to edit a row of data by clicking on the name of the person in the listbox, which will then prefill the textbox with their data, I will edit and resubmit to that row. It should be easy, but I am having difficulty submitting to every column and also bringing back and submitting DTPicker data and Checkboxes.
My code is below thanks for your help!!!
This is to pull the information from the sheet:
and now to publish over the top:
I'm sure this has been asked before, but I can't seem to find the answer.
I have a userform that is currently submitting data to the "Database" tab by userform, I want to be able to edit a row of data by clicking on the name of the person in the listbox, which will then prefill the textbox with their data, I will edit and resubmit to that row. It should be easy, but I am having difficulty submitting to every column and also bringing back and submitting DTPicker data and Checkboxes.
My code is below thanks for your help!!!
This is to pull the information from the sheet:
Code:
Private Sub ListBox1_Click()
Frame2.Visible = True
CommandButton3.Visible = True
CommandButton1.Visible = False
Dim ws As Worksheet, T As Range
Set ws = Sheets("Database")
Set T = ws.Range("A:A").Find(ListBox1.Column(0), _
LookIn:=xlValues, LookAt:=xlWhole)
T.Activate
TextBox1.Text = ActiveCell.Offset(0, 0)
TextBox2.Text = ActiveCell.Offset(0, 1)
DTPicker1.Value = ActiveCell.Offset(0, 2)
DTPicker2.Value = ActiveCell.Offset(0, 3)
CheckBox1.Value = ActiveCell.Offset(0, 4)
DTPicker3.Value = ActiveCell.Offset(0, 5)
On Error Resume Next
DTPicker4.Value = ActiveCell.Offset(0, 6)
CheckBox2.Value = ActiveCell.Offset(0, 7)
DTPicker5.Value = ActiveCell.Offset(0, 8)
DTPicker6.Value = ActiveCell.Offset(0, 9)
CheckBox3.Value = ActiveCell.Offset(0, 10)
DTPicker7.Value = ActiveCell.Offset(0, 11)
DTPicker8.Value = ActiveCell.Offset(0, 12)
CheckBox4.Value = ActiveCell.Offset(0, 13)
DTPicker9.Value = ActiveCell.Offset(0, 14)
DTPicker10.Value = ActiveCell.Offset(0, 15)
CheckBox5.Value = ActiveCell.Offset(0, 16)
DTPicker11.Value = ActiveCell.Offset(0, 17)
DTPicker12.Value = ActiveCell.Offset(0, 18)
CheckBox6.Value = ActiveCell.Offset(0, 19)
DTPicker13.Value = ActiveCell.Offset(0, 20)
DTPicker14.Value = ActiveCell.Offset(0, 21)
CheckBox7.Value = ActiveCell.Offset(0, 22)
DTPicker15.Value = ActiveCell.Offset(0, 23)
DTPicker16.Value = ActiveCell.Offset(0, 24)
CheckBox8.Value = ActiveCell.Offset(0, 25)
DTPicker17.Value = ActiveCell.Offset(0, 26)
DTPicker18.Value = ActiveCell.Offset(0, 27)
CheckBox9.Value = ActiveCell.Offset(0, 28)
DTPicker19.Value = ActiveCell.Offset(0, 29)
DTPicker20.Value = ActiveCell.Offset(0, 30)
End Sub
and now to publish over the top:
Code:
Private Sub CommandButton3_Click()'submit change
Dim ws As Worksheet, T As Range
Set ws = Sheets("Database")
ActiveCell.Offset(0, 0) = TextBox1.Text
ActiveCell.Offset(0, 1) = TextBox2.Text
ActiveCell.Offset(0, 2) = DTPicker1.Value
ActiveCell.Offset(0, 3) = DTPicker2.Value
ActiveCell.Offset(0, 4) = CheckBox1.Value
ActiveCell.Offset(0, 5) = DTPicker3.Value
ActiveCell.Offset(0, 6) = DTPicker4.Value
ActiveCell.Offset(0, 7) = CheckBox2.Value
ActiveCell.Offset(0, 8) = DTPicker5.Value
ActiveCell.Offset(0, 9) = DTPicker6.Value
ActiveCell.Offset(0, 10) = CheckBox3.Value
ActiveCell.Offset(0, 11) = DTPicker7.Value
ActiveCell.Offset(0, 12) = DTPicker8.Value
ActiveCell.Offset(0, 13) = CheckBox4.Value
ActiveCell.Offset(0, 14) = DTPicker9.Value
ActiveCell.Offset(0, 15) = DTPicker10.Value
ActiveCell.Offset(0, 16) = CheckBox5.Value
ActiveCell.Offset(0, 17) = DTPicker11.Value
ActiveCell.Offset(0, 18) = DTPicker12.Value
ActiveCell.Offset(0, 19) = CheckBox6.Value
ActiveCell.Offset(0, 20) = DTPicker13.Value
ActiveCell.Offset(0, 21) = DTPicker14.Value
ActiveCell.Offset(0, 22) = CheckBox7.Value
ActiveCell.Offset(0, 23) = DTPicker15.Value
ActiveCell.Offset(0, 24) = DTPicker16.Value
ActiveCell.Offset(0, 25) = CheckBox8.Value
ActiveCell.Offset(0, 26) = DTPicker17.Value
ActiveCell.Offset(0, 27) = DTPicker18.Value
ActiveCell.Offset(0, 28) = CheckBox9.Value
ActiveCell.Offset(0, 29) = DTPicker19.Value
ActiveCell.Offset(0, 30) = DTPicker20.Value
End Sub