Hello,
I have setup a userform with 10 labels, 10 textboxes and 1 command button.
Labels are as follows -
Agents
Raised Time (linked to A6)
Initiated Time
End Time
No of Pax
F No
Agency Name
Funds
Approver
Yes No
Below is the code used to update data in specific columns on sheet1
Requirement -
I -
Macro should update all the datas in their respective columns depending on numbers mentioned in textbox5 (label is No of Pax)
Ex :-
If number entered is 3, then macro should paste all the data thrice in the respective columns.
If number entered is 5, then macro should paste all the data 5 times in the respective columns
II -
Don't know how to get below piece of code to work
Above code will be used to update textbox3 (label is Initiated Time) when the userform is activated, and, when clicked on command button the respective column will reflect the date and time.
III - (If Possible)
Looking for a code that will update date and time in textbox4 (label is End Time) when clicked in the textbox. The format is - dd-mm-yy hh:mm.
(Option should be provided to change the format)
Requesting to provide complete working code.
Have attached sample sheet.
I have setup a userform with 10 labels, 10 textboxes and 1 command button.
Labels are as follows -
Agents
Raised Time (linked to A6)
Initiated Time
End Time
No of Pax
F No
Agency Name
Funds
Approver
Yes No
Below is the code used to update data in specific columns on sheet1
Code:
Private Sub CommandButton1_Click()
erow = Sheet1.Cells(Rows.Count, 8).End(xlUp).Offset(1, 0).Row
Cells(erow, 8) = TextBox1.Text
erow = Sheet1.Cells(Rows.Count, 11).End(xlUp).Offset(1, 0).Row
Cells(erow, 11) = TextBox2.Text
erow = Sheet1.Cells(Rows.Count, 12).End(xlUp).Offset(1, 0).Row
Cells(erow, 12) = TextBox3.Text
erow = Sheet1.Cells(Rows.Count, 13).End(xlUp).Offset(1, 0).Row
Cells(erow, 13) = TextBox4.Text
erow = Sheet1.Cells(Rows.Count, 19).End(xlUp).Offset(1, 0).Row
Cells(erow, 19) = TextBox5.Text
erow = Sheet1.Cells(Rows.Count, 20).End(xlUp).Offset(1, 0).Row
Cells(erow, 20) = TextBox6.Text
erow = Sheet1.Cells(Rows.Count, 21).End(xlUp).Offset(1, 0).Row
Cells(erow, 21) = TextBox7.Text
erow = Sheet1.Cells(Rows.Count, 22).End(xlUp).Offset(1, 0).Row
Cells(erow, 22) = TextBox8.Text
erow = Sheet1.Cells(Rows.Count, 23).End(xlUp).Offset(1, 0).Row
Cells(erow, 23) = TextBox9.Text
'clear the data
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
End Sub
Requirement -
I -
Macro should update all the datas in their respective columns depending on numbers mentioned in textbox5 (label is No of Pax)
Ex :-
If number entered is 3, then macro should paste all the data thrice in the respective columns.
If number entered is 5, then macro should paste all the data 5 times in the respective columns
II -
Don't know how to get below piece of code to work
Code:
TextBox3.Value = Now
TextBox3.Value = Format(TextBox1.Value, "dd-mm-yy hh:mm")
End Sub
Above code will be used to update textbox3 (label is Initiated Time) when the userform is activated, and, when clicked on command button the respective column will reflect the date and time.
III - (If Possible)
Looking for a code that will update date and time in textbox4 (label is End Time) when clicked in the textbox. The format is - dd-mm-yy hh:mm.
(Option should be provided to change the format)
Requesting to provide complete working code.
Have attached sample sheet.