change this "Smith, John" to this "John Smith" with VBA

Mr_Ragweed2

Board Regular
Joined
Nov 11, 2022
Messages
145
Office Version
  1. 365
Platform
  1. Windows
Hello and sorry for the crappy subject header. As stated i need to change "Smith, John" to "John Smith" but the name could be "Experticus, Vba" to "Vba Experticus" - dynamic length of each. I assuming it has something to do with" LEN", but that is one area that i cannot get to make sense to me - the code just looks like a bunch of commas.
I asked a very follow up question in one of my other posts but i thought it should probably be a different post since it was not my original question. (I apologize if that breaks the duplicate post rules. If so, please refer to this post instead.) vba to retrieve dynamic username for file save

Thanks in advance!
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
What line of VBA code is yielding the result of 'Smith, John' ?

Is 'Smith, John' being saved into a variable?
 
Upvote 0
It is actually the result of a username lookup. Right now as
VBA Code:
MsgBox Application.UserName
but i'm sure i will need to paste that result in a cell and then perform the operation i need.
 
Upvote 0
Assuming you will have ', ' in the result of Application.UserName ... Try the following:
VBA Code:
    Dim UsernameReversed    As String
    Dim UsernameStringArray As Variant
'
    UsernameStringArray = Split(Application.UserName, ", ")
'
    UsernameReversed = UsernameStringArray(1) & " " & UsernameStringArray(0)

That should put 'John Smith' into the variable named UsernameReversed
 
Upvote 0
Solution
Oh wow. That's so nice!
Thank you so very much.

I think i can handle the rest from here as i need to concatenate a few things onto it.
 
Upvote 0

Forum statistics

Threads
1,223,889
Messages
6,175,224
Members
452,620
Latest member
dsubash

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