+ Reply to Thread
Results 1 to 3 of 3

Split text string to different columns

Hybrid View

liarliar Split text string to... 06-04-2008, 03:54 AM
mudraker Try this macro It assumes... 06-04-2008, 08:24 AM
Shijesh Kumar Hi, Alternatively you can... 06-04-2008, 09:13 AM
  1. #1
    Registered User
    Join Date
    02-20-2008
    Posts
    28

    Split text string to different columns

    I have a large amount of data and want to split the data into four coloumns.The slpit parameters are fixed.

    First coloumn will have the time stamp - [*27/05/2008 13:08:23 SH*]
    Second coloumn query type- Client Query
    Third Colomn - Date (which is just after Query)
    Forth coloumn- Rest of the text
    Attached Files Attached Files

  2. #2
    Valued Forum Contributor mudraker's Avatar
    Join Date
    11-10-2003
    Location
    Melbourne, Australia
    Posts
    3,983
    Try this macro
    It assumes data in column A
    Places data in columns B to E of same row

    Sub SplitText()
       Dim sTxt As String
       Dim iPos(1) As Integer
       Dim l4Row As Long
       
       For l4Row = 1 To Cells(Rows.Count, "a").End(xlUp).Row Step 1
          sTxt = Cells(l4Row, "a").Value
          iPos(0) = InStr(1, sTxt, "]")
          Cells(l4Row, "b").Value = Left(sTxt, iPos(0))
          iPos(1) = InStr(iPos(0), sTxt, "Query")
          Cells(l4Row, "c").Value = Mid(sTxt, iPos(0) + 3, (iPos(1) - iPos(0)) + 2)
          Cells(l4Row, "d").Value = Mid(sTxt, iPos(1) + 6, 8)
          Cells(l4Row, "e").Value = Mid(sTxt, iPos(1) + 15)
       Next l4Row
    End Sub
    Please Read Forum Rules Before Posting
    Wrap VBA code by selecting the code and clicking the # icon or Read This
    How To Cross Post politely

    Top Excel links for beginners to Experts

    If you are pleased with a member's answer then use the Scales icon to rate it
    If my reply has assisted or failed to assist you I welcome your Feedback.

  3. #3
    Valued Forum Contributor Shijesh Kumar's Avatar
    Join Date
    05-26-2008
    Location
    Bangalore / India
    MS-Off Ver
    2000
    Posts
    717

    Cool

    Hi,

    Alternatively you can achieve the same by using formula as well

    
    For first column:
    =LEFT(A1,SEARCH("]",A1))
    
    For second column:
    =MID(A1,LEN(B1)+3,SEARCH("Query",A1,LEN(B1))-LEN(B1)+3)
    
    for third column:
    =MID(A1,LEN(B1)+LEN(C1)+3,8)
    
    for forth column:
    =RIGHT(A1,LEN(A1)-LEN(B1)-LEN(C1)-LEN(D1)-4)

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Using a countif function for text string data.
    By Stevie-B in forum Excel Formulas & Functions
    Replies: 14
    Last Post: 03-11-2008, 11:54 AM
  2. How to make a formula from a text string?
    By Helsinghof in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-28-2007, 09:07 AM
  3. Excel in Office 12: text to columns
    By nuuker in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-06-2007, 11:17 AM
  4. Splitting Text Across Columns
    By soma2004 in forum Excel General
    Replies: 1
    Last Post: 07-27-2007, 06:38 PM
  5. Convert cell reference to text string
    By packe in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 02-08-2007, 09:56 AM

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