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.
 
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?


what do you mean by that? I am using Excel 2011, I dont know if that is because of that... But whenever I type in the txtIngredients and txtProcedure textboxes, in order to create another line, I press ENTER key to go to another line... And when I saved it, it just form in single line...

This is your code right? I didn't change anything with it so far..


Code:
With ThisWorkbook.Sheets.Add(after:=Sheets(ThisWorkbook.Sheets.Count))        .Name = TextBox1
        .Range("B2") = StrConv(Me.TextBox1, vbUpperCase)
        .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
 
Upvote 0
Well, I'm using Excel (xls) and you are using Office (xlm). Can you figure out how to save your file as an xls file and put it on Box.com? Or can you save the file to disk and then open it with Office? (I can read my file through the Box.com link I gave in Excel)
 
Upvote 0
Same story here... empty file.

I think this may be an end of line character problem. I'll get back to you ...

tlowry
 
Upvote 0
Here's another go at it.

I've replaced the end of line indicators (CRLF and LF) with CR and split the lines from the multi-line TextBoxes by CRs. I hope this works (it does here)

tlowry


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(FixLines(Me.TextBox3), vbCr)
        For i = 0 To UBound(LinesTB3)
            .Range("B7").Offset(i, 0) = LinesTB3(i)
        Next i
        linesTB4 = Split(FixLines(Me.TextBox4), vbCr)
        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
Function FixLines(sLine) As String
    FixLines = ""
    linehold = Replace(sLine, vbCrLf, vbCr)
    FixLines = Replace(linehold, vbLf, vbCr)
End Function
 
Upvote 0
You're such a heaven sent tlowry!! Works perfect! Thank you so much! I finally got this to work (because of you!)... Thank you!!!
 
Upvote 0
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 a2, B2, c2 and d2 respectively.
Please help! Thank you.

Hi all,

i need to do this same function but i need to save data in same worksheet one cell after another(i.e next values need to be saved in a3 ,b3 and so on)

Please me
 
Upvote 0

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