Transferring data from textbox to cell

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Transferring data from textbox to cell

Post by jimpatel1993 »

Hi

Does anyone know what is the vba code for transferring textbox value to certain cell in certain sheets please?
That is I have textbox3 and everytime when textbox3 is updated I would like to transfer that information to sheet 1 b7, b8, b9, b10 please


Thanks

User avatar
HansV
Administrator
Posts: 78439
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Transferring data from textbox to cell

Post by HansV »

Code: Select all

Private Sub TextBox3_AfterUpdate()
    Dim m As Long
    With Worksheets("Sheet1")
        m = .Range("B" & .Rows.Count).End(xlUp).Row + 1
        If m < 7 Then m = 7
        .Range("B" & m).Value = Me.TextBox3.Value
    End With
End Sub
Best wishes,
Hans

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Transferring data from textbox to cell

Post by jimpatel1993 »

Thanks a lot for your kind reply.
That is very helpful
Actually I wanted to transfer to only cells like b6 b7 b8 and b9
I think I am doing something wrong as the data is transferring to next empty cell in the column b.
Am I doing something wrong?
As this code is adding new value next to available cells. The issue is I am looking to delete and transfer new value each time when text box is updated pls to the same cells.

Sorry about this

Thanks again

User avatar
HansV
Administrator
Posts: 78439
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Transferring data from textbox to cell

Post by HansV »

Apparently I interpreted your request incorrectly.

TextBox3 contains a single value. Do you want to transfer that value to all cells in B6:B9? If so:

Code: Select all

Private Sub TextBox3_AfterUpdate()
     Worksheets("Sheet1").Range("B6:B9").Value = Me.TextBox3.Value
End Sub
Best wishes,
Hans

jimpatel1993
2StarLounger
Posts: 153
Joined: 31 Jan 2021, 09:12

Re: Transferring data from textbox to cell

Post by jimpatel1993 »

Thanks a lot for your help.
Its work brilliantly
Thanks again