Edit data of previously submitted row with userform

jacob1234

New Member
Joined
Aug 16, 2016
Messages
37
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:

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
 

Excel Facts

Test for Multiple Conditions in IF?
Use AND(test, test, test, test) or OR(test, test, test, ...) as the logical_test argument of IF.
You haven't mentioned what your difficulties are. As is the code doen't look wrong per se.
 
Upvote 0
I'm sorry, I am not sure what you mean? Please be as specific as you can. If data is placed in the wrong cells, mention which line of code this is about, what cell the data goes into and what cell you expect the data to go into, any runtime error(s) you get, which codeline causes them etc. etc..
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top