• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Textbox macro to update data in specific range

Bimmy

Member
Hi,

I have a userform with 11 textboxes and 1 command button,

Data entered in the first 10 textboxes are updated in specific columns on sheet1 from row 2 onwards.

Below is the code

Code:
Const F = "dd-mm-yy hh:mm"


Private Sub CommandButton1_Click()
    N% = Val(TextBox11.Text)
    If N < 1 Then TextBox10.SetFocus: Beep: Exit Sub
     V = [{8,11,12,13,16,19,20,21,22,23}]
    r& = Sheet2.Cells(Sheet2.Rows.Count, V(1)).End(xlUp)(2).Row
For c% = 1 To UBound(V)
    Sheet2.Cells(r, V(c)).Resize(N).Value = Me.Controls("TextBox" & c).Text
    Me.Controls("TextBox" & c).Text = ""
Next
    UserForm_Initialize
End Sub


Private Sub TextBox2_Enter()
    TextBox2.Text = Format$(Now, F)
End Sub


Private Sub UserForm_Initialize()
     TextBox3.Text = Format$(Now, F)
    TextBox11.Text = "1"
End Sub
Private Sub TextBox4_Enter()
    TextBox4.Text = Format$(Now, F)
End Sub

Since range D2:M19 will be used for manual updation of data, I would like the macro to update the data in range D20:M30.

Kindly assist.

Have attached sample sheet.
 

Attachments

  • Approve2.xlsb
    38.5 KB · Views: 3
Hi:
".End(xlUp)(2)" this part of your code is basically for offsetting the rows, if you want to get the data from 20th row drag you headings down to the 19th row.

Thanks
 

Attachments

  • Approve2.xlsb
    35.3 KB · Views: 4
Hi Nebu,

Thanks for responding.

The heading will be on row 1 and will not change.

There are few comments and data's that needs to be manually updated in range D2:M19. That's why I want the macro to be update data inserted in userform from range D20:M30.
 
Hi:

Here is a cheeky way of doing this. Copy the heading row to row 19 color the font as white. the macro will paste the data from row 20.

Thanks
 

Attachments

  • Approve2.xlsb
    38.3 KB · Views: 3
Back
Top