Concatenation Question

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
701
Office Version
  1. 365
Platform
  1. Windows
I have what should be a simple task. I'm trying to concatenate some cells to complete a name. I didn't have an issue before I added the middle initial to the formula, but now I'm struggling. I've searched the forum, but only see concatenation examples for First and Last names, not anything with 4 parameters that accounts for missing data (MI and/or Suffix).

The basic layout is below, with expected results. Here's the formula that I'm using, that is not working:

=IF(G3="",IF(E3="",D3&" "&F3,IF(G3="",D3&" "&E3&" "&F3,IF(E3="",D3&" "&F3&" "&G3,D3&" "&E3&" "&F3&" "&G3))))

Column DColumn EColumn FColumn GColumn H
FirstMILastSuffixName
TommyJ.BoySr.Tommy J. Boy Sr.
TommyBoySr.Tommy Boy Sr.
TommyJ.BoyTommy J. Boy
TommyBoyTommy Boy

<tbody>
</tbody>
 
hmmm....here's where the code lies within the userform data entry piece. I wonder (and am looking it up), if instead of clicking on the txt box, can the formula be invoked when the user tabs to the field? It would be natural progression as they work through the form.
 
Upvote 0

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Like this
Code:
Private Sub txt_Name_Enter()
Me.txt_Name.Value = Trim(Me.txt_First.Value & Me.txt_MI.Value & Me.txt_Last.Value & Me.txt_Suff.Value)

End Sub
But you may want to lock the txtbox to prevent it from being changed
 
Upvote 0
Ok, so I implemented that sub and it's concatenating the text fields, but it's not adding any spaces. I changed the code to this, and it's still omitting the spaces. I also tried it without the TRIM and it's still omitting the spaces. What I'm seeing is TommyJ.BoySr. instead of Tommy J. Boy Sr.

Code:
Me.txt_Name = Trim(Me.txt_First.Value & " " & Me.txt_MI.Value & " " & Me.txt_Last.Value & " " & Me.txt_Suff.Value)
 
Upvote 0
I'm the exact opposite! Its adding all the spaces.
It looks as though the VBA function Trim & the Excel function work differently.
Whilst this worked for me
Code:
Private Sub txt_Name_Enter()
Me.txt_Name = WorksheetFunction.Trim(Me.txt_First.Value & " " & Me.txt_MI.Value & " " & Me.txt_Last.Value & " " & Me.txt_Suff.Value)
End Sub
I'm not sure what to advise, if you're not getting any spaces.
 
Upvote 0
Now we're cooking with crisco! Thank you so much!!! Especially for not making me feel like an idiot for asking what are probably simple questions.
 
Upvote 0
Glad to help & thanks for the feedback.
 
Upvote 0
Hopefully you don't mind, but I have another question that's been plaguing me for a few weeks. I have 5 sets of similar elements as the ones below; that represent different services offered to the Client. What I'm trying to do is to have VBA identify when it's time to insert the next due date (shown in row3). Right now, I have it calculated off the value in the DP Pymt Status column, but that's not through VBA.

A few issues that complicate this for me are:
1. A Client can sign up for, or end services at any time.
2. Not all payment frequencies are the same (Monthly, Weekly, Bi-Weekly).
3. I don't want to get more than 1 payment into the future, as it would really clutter the spreadsheet up.
4. I will have to be able to navigate to the next payment due via a userform. I haven't really gotten far enough into this to think how I would do that.
5. I anticipate having 50+ sheets (that can grow), one for each Client, so I'm hoping it's some sort of code that can be entered in one module, without having to name each sheet.
DP StartDP Next PymtDP AmtDP FreqDP PaidDP Amt PaidDP Pymt DateDP Pymt StatusDP Net Due
9/4/201709/01/17$200.00BLate
09/15/17

<colgroup><col><col><col><col><col><col><col><col><col></colgroup><tbody>
</tbody>

I'm not asking for the code to solve this, but instead, recommendations on how I best structure this to solve for it on my own.
 
Upvote 0
Sort of. I was able to make a little progress on it since that post. Was hoping you might have some insight.
 
Upvote 0
I'll have a look at it tomorrow, but everything needs to remain on that thread.
 
Upvote 0

Forum statistics

Threads
1,215,634
Messages
6,125,934
Members
449,274
Latest member
mrcsbenson

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