+ Reply to Thread
Results 1 to 3 of 3

Triming data in a cell?

Hybrid View

  1. #1
    Registered User
    Join Date
    12-15-2004
    Posts
    64

    Triming data in a cell?

    I have a column of postcode area in which each cell can have 1 or more areas for example this is the data in one of the cells

    SO25, SO26, SO27, SO28, SO29, SO30, SO31, SO32, SO33, SO34, SO35, SO36, SO37, SO38, SO39, SO40

    I am trying to split the areas into into individual cells i.e. SO25 would appear in A1 then SO26 in A2 etc etc but having no joy.

    Can anybody help?

    Regards

    Adrian

  2. #2
    Forum Contributor stevebriz's Avatar
    Join Date
    09-07-2006
    Location
    Santiago Chile
    Posts
    389
    somthing like this will work for you:


    Private Sub CommandButton1_Click()
    
        Dim txt As String
        Dim x As Variant
        Dim i As Long
        txt = Range("B2").Text ' the data you want to split is in cell B2
        'MsgBox txt
        x = Split(txt, ",")
        For i = 0 To UBound(x)
       Cells(1, i + 1).Value = Trim(x(i)) ' puts in row 1 starting a column A
           
        Next i
    End Sub
    VBA - The Power Behind the Grid

    Posting a sample of your workbook makes it easier to look at the Issue.

  3. #3
    Registered User
    Join Date
    12-15-2004
    Posts
    64
    Thanks for that Steve

    It is a step in the right direction.

    Much appreciated

    Adrian

+ 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