自动换行;限制每行的字符数

时间:2015-03-13 17:55:21

标签: excel vba concatenation textwrapping

我正在创建一个公式或vba来限制每行连接的信息。我限制空间" 49个字符"到我需要将其粘贴到的应用程序中。

是否有一个公式,我可以用它来描绘这些信息,几乎没有操纵。可能没有分词?

以下是我目前使用的公式示例,包含文字: 符合此信息的单元格是" EM"

  

= IF(AF1143 = 0,"无需工具/无问题",连续("供应商:",T1143,"将构建&# 34;,CA1143,"工具能够始终如一   产生PN",I1143,"每个公司& ",E1143,"提供发布   绘图和3D数据满足100%的生产要求   生命的",G1143,"计划和服务。工具付款条款:1/3   关于工具PO发行的收据,收到首次关闭部件的1/3   {第一条提交} {{包括完整布局数据和工具   数据表和1/3收到PPAP批准来自"," ",E1143,&#34 ;,   签署的PSW足以满足此确认要求。 ","请留下来   请联系公司买方,并提供以上所有信息   延迟付款。上述截止日期仅为估算值。实际日期是   由","确定",E1143," "&#34 ;. ","每周工具进度报告(TPR)   必须提供给NPC,"," ",E1143,&#34 ;;必须提供这些TRP   每两周一次。如果不这样做将导致付款延迟   {TPR样本可以从Supplier Portal / SQAM查看。关键事件   时间:请参考",E1143," "," NPC时间表 - 如果NPC时间表是   不可用请联系买家索取。原产地:工具   将在以下时间制作:",BW1143,"离岸价:",T1143," ",BW1143,附加   信息:PN," ",I1143," ",K1143," ","工具总数:",AF1143,"   ","每个工具的成本:",AR1143," ","推理:",AS1143," ""详细   工具信息:",AT1143," "," ECI:{if applicable}:",DW1143,"   ","提前期:",EL1143," "," SOP假设:",O1143," ""质量   生产/生活计划{年}:",Q1143," Tool Go发送给供应商:   ",DG1143," ","设计审核日期:",DE1143," ",DF1143," "" CER   追踪号码#:",FB1143," ","帐号#",FC1143," ""工装   PO#:",EN1143,"。"))

1 个答案:

答案 0 :(得分:0)

这就是我的意思:

Public Function LimitLine (StringToLimit As String, NumberOfLetters As Integer) As String
    Dim TheString As String
    Dim Output As String
    Dim CommaLoc As Integer
    Dim BlankSpaceLoc As Integer

    Output = ""
    TheString = StringToLimit

    Do WHile Len(TheString) > NumberOfLetters
        BlankSpaceLoc = InStrRev(Left(TheString, NumberOfLetters), " ")
        CommaLoc = InStrRev(Left(TheString, NumberOfLetters), ",")
        If BlankSpaceLoc > CommaLoc Then
              Output = Output & Left(TheString, BlankSpaceLoc) & vbCr
              TheString = Right(TheString, Len(TheString) - BlankSpaceLoc)
        Else
              Output = Output & Left(TheString, CommaLoc) & vbCr
              TheString = Right(TheString, Len(TheString) - CommaLoc)
        End If
    Loop
    Output = Output & TheString
    LimitLine = Output
End Function