Combining text box values

Adam19931

New Member
Joined
Jun 22, 2021
Messages
4
Office Version
  1. 365
Platform
  1. Windows
Hi all, I have a user form that inputs the data into a master sheet. I am looking to amend the VBA code below so the values from text boxes frmForm.txtOrder1 and frmForm.txtOrder2 are pulled into the worksheet combined, separated by a comma and ignore empty fields. At present they are pulled in separately and then combined using a textjoin formula. Is there a way to do this using VBA please?

VBA Code:

With sh

.Cells(irow, 1) = "3T-" & irow - 1
.Cells(irow, 2) = frmForm.txtWeek.Value
.Cells(irow, 3) = frmForm.txtOrder1.Value
.Cells(irow, 4) = frmForm.txtOrder2.Value
.Cells(irow, 5) = frmForm.txtDestName.Value
.Cells(irow, 6) = frmForm.txtDestLocation.Value

End With
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
Have you tried something like this:
VBA Code:
.Cells(irow, 3) = WorksheetFunction.TextJoin(",", True, frmForm.txtOrder1.Value, frmForm.txtOrder2.Value)
 
Upvote 0
Solution

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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