使用错误的函数名称调用函数,不带括号

时间:2013-12-03 11:26:25

标签: excel vba excel-vba

Sub TestConc()
    Dim s As String
    s = ConcatenateRange Range("A1:A4")
    MsgBox s
End Sub

Function TraceRangeString(r As Range) As String
    For Each cell In r
        TraceRangeString = TraceRangeString & cell.Address & ": " & cell & " " & Chr(13)
    Next cell
End Function

为什么我会在s = ConcatenateRange Range("A1:A4")上收到语法错误?

1 个答案:

答案 0 :(得分:1)

这应该有效

Sub TestConc()
    Dim s As String
    s = TraceRangeString(Range("A1:A4"))
    MsgBox s
End Sub

Function TraceRangeString(r As Range) As String
    For Each cell In r
        TraceRangeString = TraceRangeString & cell.Address & ": " & cell & " " & Chr(13)
    Next cell
End Function