PDA

View Full Version : Help with VBA code in data entry form



Adin 84
04-23-2019, 04:31 AM
Dears,

I would like to kindly ask you for your help/advise regards vba code. I need to split multiple lines filled in text box to separate lines in excel after saving.So far, all info in text box saved in on excel cell - need to separate each line in text box to cells in excel.

See attached picture, Assume it will be clear for what I'm looking for.
24118
btw...I'm vba beginer, so please be patient :D

THX Adin 84

rothstein
04-23-2019, 05:12 AM
Put this code in the submit button's Click event...

Dim Data As Variant
Data = Split(TextBox1.Text, vbLf)
Range("A1").Resize(UBound(Data) + 1).Value = Application.Transpose(Data)

Adin 84
04-23-2019, 05:49 AM
Many thanks Sir,

seems it will be working well.
Just need one small adjustment. I forgot to mention, that "storage" is in excel table which is located in different sheet. Now it's loading data to the same sheet where data entry interface is located.
Need to save data in Column E in sheet called "Database"

Any advise?

THX
Adin

rothstein
04-23-2019, 06:27 AM
Many thanks Sir,

seems it will be working well.
Just need one small adjustment. I forgot to mention, that "storage" is in excel table which is located in different sheet. Now it's loading data to the same sheet where data entry interface is located.
Need to save data in Column E in sheet called "Database"

Any advise?

Change the last line of code that I gave you to this...

Sheets("Database").Range("E1").Resize(UBound(Data) + 1).Value = Application.Transpose(Data)