+ Reply to Thread
Results 1 to 4 of 4

Truncate cell content after a certain character

  1. #1
    Registered User
    Join Date
    09-19-2006
    Posts
    2

    Truncate cell content after a certain character

    HI,

    how can I perform the following through a macro (I'm an absolute beginner with macros :-/)

    I've got the following information in a cell:

    category level one > category level two

    I need to find a way to truncate the content of this cell after the ">" sign.

    Can anyone think of a way of doing this?

    THanks so much for your help!

    Kai

  2. #2
    Forum Contributor
    Join Date
    12-12-2005
    Posts
    667
    Sub Trunc()
    For i = 1 To 3
    x = Cells(i, 1).Text
    j = InStr(1, x, ">")
    Cells(i, 2) = Left(x, j)
    Next
    End Sub
    Best regards,

    Ray

  3. #3
    Registered User
    Join Date
    09-19-2006
    Posts
    2
    hi there,

    thanks so much for your reply. Unfortunately, I can't figure out how to integrate it into my macro. As I said I'm an absolute beginner with macros! ;-)

    I'd like to give you some more info and maybe you can help me with the integration.

    ---

    The current macro copies the whole column H from spreadsheet "Default Sheet" to spreadsheet "Shopferret" starting from column A2:

    Please Login or Register  to view this content.
    The spreadsheet has several thousand rows. On the spreadsheet "Shopferret" I now need to truncate everything behind the ">" in Column A starting from row 2.

    Do you know how I intergrate your code part into this macro snippet?

    THANKS A LOT for your help! Much appreciated...

  4. #4
    Forum Contributor
    Join Date
    11-11-2005
    Posts
    267
    Sub CopyingSht()
    Dim WS1 as Worksheet
    Dim WS2 as WorkSheet

    set WS1= Sheets("Default Sheet")
    set WS2=Sheets("Shopferret")

    WS1.Range("H2:H65536").Copy WS2.Range("A2")

    For each c in Range("A2", Cells(rows.Count, "A").End(xlUp))
    x = c.Text
    j = InStr(1, x, ">")
    c.value = Left(x, j)
    Next

    End Sub
    HTH
    Myles

    ...constantly looking for the smoother pebble while the whole ocean of truth lies before me.

+ 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