Saving text from a Command Button

  • Hello,
    i have no idea what to look for on here as i am sure this question will be somewhere else.
    I have tried to find a set of VBA functions for this, but no idea what to ask for.
    If someone could please point me int he right direction, i would appreciate it.


    Requirements:
    Press Command Button1 to allow Data to be sent to Sheet2 and added to A2-D2 and then saved, next command onto the next line A3-D3
    At the same time the Text sent to Text on Sheet2 E2 saved the same way as the Data.. Also the text sent to the TextBox1, which is also saved and added in Succession.

  • Hello,


    You can test following


    Code
    1. Private Sub CommandButton1_Click()
    2. Dim last As Long
    3. last = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row + 1
    4. Sheet2.Range("A" & last & ":" & "D" & last).Value = Sheet1.Range("B6:E6").Value
    5. End Sub


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • I left a Like and feel like saying Thank You too... Excellent Carim, as now the Data section is copying over to Sheet 2 and also selecting the next row for new additions.


    Now i need to know how to transfer the text over, i guess that will be the same way..


    One thing though... I don't know how to transfer the text to a Text Box though.. I choose a VBA text Box as i need to use a scroller as the new additions grow.

  • Glad to hear macro is working fine :wink:


    Thanks for your Thanks ...AND for the Like ..:smile:


    Sorry ... but I do not understand your last question ...

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • I think i need to use something else?. I needed somewhere to add text to, but also keep existing text when updated. I thought i should use a TextBox, but it looks like it can be modified and not locked.
    I thought i should use a VBA TexBox to be able to use a scroll bar. I only know of using a cell.


    I was totally scratching my head for a week then... So happy with the tricks you have shown me though.. Brilliant.


    Here is the finished File in attachments for anyone to suss out and use.

  • You can always have a copy of the original text ... AND its modified version in two separate cells ...


    Glad you could solve your problem.

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)

  • Hello,


    Below is the code modified :


    Code
    1. Private Sub CommandButton1_Click()
    2. Dim last As Long
    3. last = Sheet2.Cells(Rows.Count, 1).End(xlUp).Row + 1
    4. Sheet2.Range("A" & last & ":" & "D" & last).Value = Sheet1.Range("B6:E6").Value
    5. Me.TextBox1.Value = Range("F6").Value
    6. Range("F6:I27").ClearContents
    7. End Sub


    Hope this will help

    If you feel like saying "Thank You" for the help received, do not hesitate to click the "Like" icon ...just below...in the bottom right corner...:)