I just wrote this for another answer: You would name it using the form using your example: appendTextToRange "[theRange]", "," .
Sub testit() appendTextToRange "A1:D4000", "hey there" End Sub Sub appendTextToRange(rngAddress As String, append As String) Dim arr() As Variant, c As Variant arr = Range(rngAddress).Formula For x = LBound(arr, 1) To UBound(arr, 1) For y = LBound(arr, 2) To UBound(arr, 2) Debug.Print arr(x, y) If arr(x, y) = "" Then arr(x, y) = append ElseIf Left(arr(x, y), 1) = "=" Then arr(x, y) = arr(x, y) & " & "" " & append & """" Else arr(x, y) = arr(x, y) & " " & append End If Next Next Range(rngAddress).Formula = arr End Sub
Daniel Cook Jul 23 '12 at 18:27 2012-07-23 18:27
source share