ipbr21054
Well-known Member
- Joined
- Nov 16, 2010
- Messages
- 5,699
- Office Version
- 2007
- Platform
- Windows
Hi,
@MAIT supplied a code for data entry from userform to worksheet where it would enter the data into the last row on my sheet.
On a new userform that i have just made i would like to use the same code in respect of entering the data from userform to worksheet BUT not in the last row.
As you can see from my code below it will be entered into Row 6
I am stuck with cleaning the code up for submitting to the worksheet.
The code i have is shown below.
@MAIT supplied a code for data entry from userform to worksheet where it would enter the data into the last row on my sheet.
On a new userform that i have just made i would like to use the same code in respect of entering the data from userform to worksheet BUT not in the last row.
As you can see from my code below it will be entered into Row 6
I am stuck with cleaning the code up for submitting to the worksheet.
The code i have is shown below.
Code:
Private Sub CommandButton1_Click()Dim i As Long
Dim x As Long
Dim ctrl As Control
Dim lastrow As Long
lastrow = ThisWorkbook.Worksheets("DATABASE").Cells(Rows.Count, 1).End(xlUp).Row
With ThisWorkbook.Worksheets("DATABASE")
.Cells(lastrow + 1, 1).Value = TextBox1.Text: TextBox1.Value = ""
.Cells(lastrow + 1, 2).Value = TextBox2.Text: TextBox2.Value = ""
.Cells(lastrow + 1, 3).Value = TextBox3.Text: TextBox3.Value = ""
.Cells(lastrow + 1, 4).Value = TextBox4.Text: TextBox4.Value = ""
.Cells(lastrow + 1, 5).Value = TextBox5.Text: TextBox5.Value = ""
.Cells(lastrow + 1, 6).Value = TextBox6.Text: TextBox6.Value = ""
.Cells(lastrow + 1, 7).Value = TextBox7.Text: TextBox7.Value = ""
.Cells(lastrow + 1, 8).Value = TextBox8.Text: TextBox8.Value = ""
.Cells(lastrow + 1, 9).Value = TextBox9.Text: TextBox9.Value = ""
.Cells(lastrow + 1, 10).Value = TextBox10.Text: TextBox10.Value = ""
.Cells(lastrow + 1, 11).Value = TextBox11.Text: TextBox11.Value = ""
.Cells(lastrow + 1, 12).Value = TextBox12.Text: TextBox12.Value = ""
.Cells(lastrow + 1, 13).Value = TextBox13.Text: TextBox13.Value = ""
.Cells(lastrow + 1, 14).Value = TextBox14.Text: TextBox14.Value = ""
.Cells(lastrow + 1, 15).Value = TextBox15.Text: TextBox15.Value = ""
.Cells(lastrow + 1, 16).Value = TextBox16.Text: TextBox16.Value = ""
TextBox2.SetFocus
TextBox2.Value = Now
TextBox1 = Format(TextBox2.Value, "dd/mm/yyyy")
End Sub
Rows("6:6").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A6").Select
Range("A6:Q6").Borders.LineStyle = xlContinuous
Range("A6:Q6").Borders.Weight = xlThin
Range("A6:Q6").Interior.ColorIndex = 6
Range("M6") = Date
Range("$Q$6").Value = "'NO NOTES FOR THIS CUSTOMER"
Range("$Q$6").HorizontalAlignment = xlCenter
Unload DatabaseInput
End Sub