Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2004
    Posts
    113

    Unanswered: macro to character truncate

    Hey guys,
    I have a data in column "L" if type general that ppoulates with long strings...basically a paragraph in each cell. How do i truncate each cell so that it limits it to 2048 characters, starting from row 2 to the end of the column with data......anything passed 2048 would jsut cutt off...

  2. #2
    Join Date
    Sep 2004
    Posts
    113
    nvm got it to work guys. If you guys need help on this here is code i used


    Sub DescTruncate()
    Dim LastRow As Long

    LastRow = Cells(Rows.Count, 12).End(xlUp).Row
    For i = 2 To LastRow
    Cells(3, i).Formula = Left(Cells(12, i), 2048)
    Next i
    End Sub

  3. #3
    Join Date
    Jan 2004
    Location
    Aberdeen, Scotland
    Posts
    1,067
    a little change here for you

    Code:
    Sub DescTruncate2()
        Dim LastRow As Long
        Dim rngNew As Range
        
        LastRow = Cells(Rows.Count, 12).End(xlUp).Row
        Set rngNew = Range(Cells(1, 3), Cells(LastRow, 3))
        
        rngNew.FormulaR1C1 = "=LEFT(RC[9],2048)"
        rngNew.Formula = rngNew.Value
        
        Set rngNew = Nothing
    End Sub
    you may find this quicker if you have lots to do see what you think
    Dave

Posting Permissions

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