Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8583873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T21:38:19+00:00 2026-06-11T21:38:19+00:00

How would that work? I don’t want to use the wizard, I want to

  • 0

How would that work?
I don’t want to use the wizard, I want to do it using VBA.

I have a column of names, first, middle, last, some with suffix (Jr, Sr)
Some of the names have multiple middle names (full names or initials)
Some sure names have 2 parts (Van der lay, de Novo).

When doing txt-to-column all I need is space, but because the number of resulting columns can be from 5 to 8 in number, I risk deleting the data in the next columns that is associated with each name.

I have set up my Sub to just add columns first, but I thought there might be something more elegant and/or efficient.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T21:38:21+00:00Added an answer on June 11, 2026 at 9:38 pm

    In VBA, the easiest fastest solution will be to count the number of separators (or the number of columns), insert the appropriate number of columns, then run the wizard.

    If you’re counting spaces, the following code would get it the max number of spaces:

    Dim shtTemp As Worksheet, lMaxSpaces As Long
    
    Set shtTemp = Sheets.Add
    shtTemp.Cells(1, 1).FormulaArray = _
        "=MAX(LEN('Sheet1!R[1]C[1]:R[1000]C[1])-LEN(SUBSTITUTE('Sheet1!R[1]C[1]:R[1000]C[1],"" "","""")))"
    lMaxSpaces = shtTemp.Cells(1, 1).Value
    
    Application.DisplayAlerts = False
    shtTemp.Delete
    Application.DisplayAlerts = True
    

    Another option without sheet insertion would be:

    Dim vArr As Variant, lMaxSpaces As Long, lLoop As Long, lSpaces As Long
    
     vArr = Selection.Value
    
    For lLoop = LBound(vArr, 1) To UBound(vArr, 1)
        lSpaces = Len(vArr(lLoop, 1)) - Len(Replace(vArr(lLoop, 1), " ", ""))
        If lSpaces > lMaxSpaces Then lMaxSpaces = lSpaces
    Next
    
    Debug.Print lMaxSpaces
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want a generic function that would work with types that have Top ,
We have a small work group that I would like to encourage to adopt
Since I'm using jQuery, any solution via that would work too. Ideally, I'd like
Is there a strategy that would work within the current Firebase offering to detect
so it would appear that the only values that actually work are 0.0, 0.5,
**EDIT: There are several options below that would work. Please vote/comment according to your
Take the following lines of code that would work fine in a c# asp.net
I'm working on a piece of software that would work well with an iTunes
Are there any guidelines to writing Google App Engine Python code that would work
I would like to compile and distribute (on .net) some python programs that work

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.