Characters.Insert Method (Excel) limits text to 255 characters

前端 未结 3 1688
情书的邮戳
情书的邮戳 2021-01-13 00:15

It is really impossible to append more than 255 chars into a single cell by VBA macro in MS Excel?

Sample code:

Option Explicit
Sub TestSub()
  Dim L         


        
3条回答
  •  孤街浪徒
    2021-01-13 00:38

    question changed with this additional comment
    https://stackoverflow.com/users/4742533/stayathome
    will return and update this

    initial answer

    You can format the partial string using characters.

    Code below appends your sample string to test string (300 characters long), then makes the last three italic, the three before that bold.

    Sub LikeThis()
    Dim StrIn As String
    
    StrIn = "aaaabbbccc"
    
    [a1] = Application.Rept("xyz", 100)
    
    [a1].Value2 = [a1].Value2 & StrIn
    
    [a1].Characters(Len([a1]) - 5, 3).Font.Bold = True
    [a1].Characters(Len([a1]) - 2, 3).Font.Italic = True
    
    End Sub
    

提交回复
热议问题