Capture Data Entered in textboxes into New Worksheet

ellehcer08

New Member
Joined
Jul 25, 2011
Messages
31
I have a userform with 4 textbox in it, and I want the information typed in those textbox to be saved in a NEW sheet on the same workbook.

For example, if I type information in those textbox, and I click the button SAVE, it will generate a new sheet and save the information there in cell B2, B3, B5 and B7 respectively. (New worksheet everytime I click SAVE).

Please help! Thank you.
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
In the form design:

1. Right click the SAVE button
2. Insert this code:
3. Test

Code:
 With ThisWorkbook.Sheets.Add
        .Range("B2") = Me.TextBox1
        .Range("B3") = Me.TextBox2
        .Range("B5") = Me.TextBox3
        .Range("B7") = Me.TextBox4
    End With
 
Upvote 0
Hi! Thanks for the code.. It seems to work alone, but if I added my code it doesn't seem to work for me.

Code:
Private Sub CommandButton1_Click()

' to rename added sheet to textbox1's information

Sheets.Add.Name = TextBox1
ActiveSheet.Move _
After:=ActiveWorkbook.Sheets(ActiveWorkbook.Sheets.Count)
       
       
End Sub


And btw, what I want is to find the next empty row (or atleast with a single line empty row -- Kinda like a recipe book outlook).
 
Upvote 0
Try:

Code:
Private Sub CommandButton1_Click()
    With ThisWorkbook.Sheets.Add(after:=Sheets(ThisWorkbook.Sheets.Count))
        .Name = "TextBox1"
        .Range("B2") = Me.TextBox1
        .Range("B3") = Me.TextBox2
        .Range("B5") = Me.TextBox3
        .Range("B7") = Me.TextBox4
    End With
End Sub

And btw, what I want is to find the next empty row (or atleast with a single line empty row -- Kinda like a recipe book outlook).

Not sure what you want here. Can you give an example?
 
Upvote 0
the code works great! thanks a lot..
though I have things I need to do with this still, and try to figure out first...but if I can't do it on my own, I'll just ask again :)
Thank you so much!!
 
Upvote 0
the code works great! thanks a lot..

this is my userform example:

textbox --- Recipe Title - txtRecipeName ----must be posted to cell B2
Source - txtSource ---- must be posted to cell B3
Ingredients - txtIngredients (multilines) ------must be posted to cell B6
Procedure - txtProcedure (multilines)

what I want in the "Procedure" is to be posted to the next 2 empty lines next to "Ingredients". The txtIngredients has multilines so it will be indefinite how many lines it can take up in the sheet.

Please see the image, it's kinda like this:

8164745735_20d6d192e9.jpg
 
Upvote 0
Does this do what you want?

Code:
Private Sub CommandButton1_Click()
    With ThisWorkbook.Sheets.Add(after:=Sheets(ThisWorkbook.Sheets.Count))
        .Name = TextBox1
        .Range("B2") = Me.TextBox1
        .Range("B3") = Me.TextBox2
        .Range("B6") = "Ingredients:"
        linesTB3 = Split(Me.TextBox3.Text, vbCrLf)
        For i = 0 To UBound(linesTB3)
            .Range("B7").Offset(i, 0) = linesTB3(i)
        Next i
        linesTB4 = Split(Me.TextBox4.Text, vbCrLf)
        startrow = 10 + UBound(linesTB3)
        .Range("B" & startrow) = "Procedure:"
        startrow = startrow + 1
        For i = 0 To UBound(linesTB4)
            .Range("B" & (i + startrow)) = linesTB4(i)
        Next i
    End With
End Sub
 
Upvote 0
hi tlowry! thanks a lot.. works great!!!

just one thing! i said that txtIngredients (or TextBox3) and txtProcedure (or TextBox4) has both MULTILINES...
so when I add the information in it.. it comes in just one line (both of them). can I make it appear on multilines as well in the sheet?

here's what happened:
8165190300_3afcbed679.jpg
8165155295_3d8d348d5e.jpg
 
Upvote 0
With this last code, the multi-line text boxes should be in multiple should be in the worksheet.

How are you putting the data in these boxes on the form? The code is looking for a CRLF to indicate new line. Did UNIX get in here?

Excel 2000
ABCD
1
2Sample Name
3Sample Source
4
5
6Ingredients:
7Sample ingredient 1
8Sample ingredient 2
9Sample ingredient 3
10Sample ingredient 4
11
12
13
14Procedure:
15Sample procedure 1
16Sample procedure 2
17Sample procedure 3
18

<colgroup><col style="width: 25pxpx"><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sample Name
 
Upvote 0

Forum statistics

Threads
1,216,172
Messages
6,129,291
Members
449,498
Latest member
Lee_ray

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top