+ Reply to Thread
Results 1 to 5 of 5

Text to column for all rows

  1. #1
    Registered User
    Join Date
    07-01-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    2

    Text to column for all rows

    Hi all,

    I'm new with VB and tried for a long time to find the answer on different forums. Since I didn't find anything I decide to post it.
    I would like to do a simple text to column. I have a lot of rows in column A. Problem is that with the following code the text to column only works for cell A1. I wish it could work for all the "non blank" cells of column A. This is the VBA code I have:

    Private Sub CommandButton1_Click()
    NewFN = Application.GetOpenFilename(FileFilter:="All Files (*.), *.", Title:="Please select a file")
    If NewFN = False Then
    ' They pressed Cancel
    MsgBox "Stopping because you did not select a file"
    Exit Sub
    Else
    Workbooks.Open Filename:=NewFN
    End If


    Selection.TextToColumns Destination:=Range("A:A"), DataType:=xlDelimited, _
    TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
    Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar:=";", FieldInfo:=Array(1, 1)


    End Sub

    Thanks and regards,

    Simon

  2. #2
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Text to column for all rows

    Use the built in function text to column

    Excel 2007 => data => text to column

    Excel 2007 (dutch) => gegevens => tekst naar kolommen
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  3. #3
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Text to column for all rows

    Maybe:

    Please Login or Register  to view this content.

  4. #4
    Registered User
    Join Date
    07-01-2013
    Location
    Belgium
    MS-Off Ver
    Excel 2010
    Posts
    2

    Re: Text to column for all rows

    Thank you!

    This works perfectly...

    I was doing it the way of oeldere but I wanted to make it easier with a VBA code.

    Thanks again

  5. #5
    Forum Expert
    Join Date
    06-12-2012
    Location
    Ridgefield Park, New Jersey
    MS-Off Ver
    Excel 2003,2007,2010
    Posts
    10,241

    Re: Text to column for all rows

    You're welcome, glad to help out and thanks for the feedback. Please comply with Forum Rule No. 9.

    9. Acknowledge the responses you receive, good or bad. If your problem is solved, please say so clearly, and mark your thread as Solved: Click Thread Tools above your first post, select "Mark your thread as Solved". Or click the Edit button on your first post in the thread, Click Go Advanced, select [SOLVED] from the Prefix dropdown, then click Save Changes. If more than two days have elapsed, the Dropdown option or Edit button will not appear -- ask a moderator to mark it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1