Forum Discussion
HeidiC1
Jul 31, 2019Copper Contributor
Applying a macro to multiple cells.
I need help with a macro issue. So, I currently have a large Excel workbook with over 1000+ cells with content in them. My issue: I have a column, column A I will call it, that has different ...
PeterBartholomew1
Jul 31, 2019Silver Contributor
I am not wildly enthusiastic about the use of the clipboard; more often than not is contains the leftovers from some past operation. It also requires references be set to the "Microsoft Forms 2.0 Object Library".
That said, the following code appears to do what you require
Sub extendName()
Dim DataObj As New MSForms.DataObject
Dim rng As Range
Dim v()
Dim i As Long
Dim S As String
DataObj.GetFromClipboard
S = DataObj.GetText
Set rng = Range("firstName")
v = rng.Value
For i = 1 To UBound(v)
v(i, 1) = v(i, 1) & " " & S
Next
rng.Value = v
End Sub