如何在Excel中的单元格中处理超过255个字符?

时间:2015-05-11 14:07:04

标签: excel vba excel-vba

我使用VBA代码将粘贴(Application.Transpose)的一些信息从表2复制到表1.代码运行良好,但是,我有几个单元格超过255个字符。

我遇到这些单元格的错误(错误13:类型不匹配)。我认为这个细胞包含超过255个字符的事实。

下面是我使用的代码:

Sub Bouton3_Cliquer()

Dim O1 As Worksheet 'déclare la variable O1 (Onglet 1)
Dim O2 As Worksheet 'déclare la variable O2 (Onglet 2)
Dim TC As Variant 'déclare la variable TC (Tableau de Cellules)
Dim D As Object 'déclare la variable D (Dictionnaire)
Dim I As Integer 'déclare la variable I (Incrément)
Dim TMP As Variant 'déclare la variable TMP (tableau TeMPoraire)
Dim TL() As Variant 'déclare la variable TL (Tableau de Lignes)
Dim K As Integer 'déclare la variable K (incrément)
Dim PL As Integer 'déclare la variable PL (Première Ligne)
Dim J As Integer 'déclare la variable J (incrément)
Dim L As Byte 'déclare la variable L (incrément)

Set O1 = Sheets("Feuil1") 
Set O2 = Sheets("evaluations") 
TC = O1.Range("B1").CurrentRegion

Set D = CreateObject("Scripting.Dictionary") 

For I = 4 To UBound(TC, 1) 
    D(TC(I, 1)) = "" 
Next I 
TMP = D.keys 
TC = O2.Range("A1").CurrentRegion 
For I = 0 To UBound(TMP, 1) 
    Erase TL 'efface le tableau TL
    K = 1 'initialise la variable K

    PL = O1.Columns(2).Find(TMP(I), O1.Range("B3"), xlValues, xlWhole).Row
    For J = 2 To UBound(TC, 1) 
            If TC(J, 1) = TMP(I) Then
            ReDim Preserve TL(1 To UBound(TC, 2) - 1, 1 To K)
            For L = 1 To UBound(TC, 2) - 1 
                TL(L, K) = TC(J, L + 1) 
            Next L 
            K = K + 1 '
        End If 'fin de la condition
    Next J 
            If K > 1 Then O1.Cells(PL, 16).Resize(UBound(TL, 2), UBound(TL, 1)).Value = Application.Transpose(TL)
Next I '

End Sub

问题在于:

If K > 1 Then 
  O1.Cells(PL, 16).Resize(UBound(TL, 2), _
      UBound(TL, 1)).Value = Application.Transpose(TL)

您是否知道如何解决此问题?

0 个答案:

没有答案