elbertzeeroone
New Member
- Joined
- Sep 22, 2023
- Messages
- 1
- Office Version
- 2013
- Platform
- Windows
Can anyone help me with my code, I'm new in VB and I want to copy only the textbox with the value to my worksheet. I Hope anyone can help me
VBA Code:
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox5.Value
.Cells(lRow, 4).Value = Me.TextBox6.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox7.Value
.Cells(lRow, 4).Value = Me.TextBox8.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox9.Value
.Cells(lRow, 4).Value = Me.TextBox10.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox11.Value
.Cells(lRow, 4).Value = Me.TextBox12.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox13.Value
.Cells(lRow, 4).Value = Me.TextBox14.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox15.Value
.Cells(lRow, 4).Value = Me.TextBox16.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox17.Value
.Cells(lRow, 4).Value = Me.TextBox18.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox19.Value
.Cells(lRow, 4).Value = Me.TextBox20.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox21.Value
.Cells(lRow, 4).Value = Me.TextBox22.Value
End With
'Copy input values to sheet.
Set ws = Worksheets("Particulars")
lRow = ws.Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).Row
With ws
.Cells(lRow, 1).Value = Me.TextBox1.Value
.Cells(lRow, 2).Value = Me.TextBox2.Value
.Cells(lRow, 3).Value = Me.TextBox23.Value
.Cells(lRow, 4).Value = Me.TextBox24.Value
End With
Attachments
Last edited by a moderator: