VBA代码无法阻止WrapText

时间:2015-07-13 14:33:20

标签: excel vba excel-vba

以下代码可防止单元格中输入的数据被包裹...

With ActiveSheet
    With .Cells(Rows.Count, "A").End(xlUp).Offset(1, 0)
        .Value = Application.Evaluate("CONCATENATE(L1,N1)")
        .WrapText = False
    End With
End With

这就像我想要的那样。但是,这个问题与.WrapText = False

有关
With ActiveSheet
    With .Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) = .Range("L1").Value2
        .WrapText = False
    End With
End With

如果我不得不猜测,我错过了在.Value之前输入的某种.WrapText = False行。我只是不知道.Value应该是什么使其成功。如果有人有解决方案,您是否也可以解释一下您如何知道.Value要放置什么?

1 个答案:

答案 0 :(得分:1)

我建议您避免在使用块定义的行中指定值:

    'this gets probably B2 only
    With ActiveSheet.Cells(Rows.Count, "B").End(xlUp).Offset(1, 0) 

        'this sets the value of B2 with the value of L1
        .Value = ActiveSheet.Range("L1").Value2
        .WrapText = False
    End With

如果您想取整个列而不是B2:

    With ActiveSheet.Range("B:B")