If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > PC based Database Applications > Microsoft Excel > macro to character truncate

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-05, 16:26
inho78 inho78 is offline
Registered User
 
Join Date: Sep 2004
Posts: 113
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...
Reply With Quote
  #2 (permalink)  
Old 03-03-05, 16:35
inho78 inho78 is offline
Registered User
 
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
Reply With Quote
  #3 (permalink)  
Old 03-04-05, 04:32
DavidCoutts DavidCoutts is offline
Registered User
 
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
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On