Forum Discussion
Sjefferson2118
Oct 26, 2023Copper Contributor
Adding data to existing cell
Hey, I was just wondering if there is a formula or add-in that I can use to add data to a cell that already has data. For example, I have a bunch of usernames in a row and would like to append the @e...
HansVogelaar
Oct 26, 2023MVP
Run this macro, after editing the constants at the beginning:
Sub AddEmail()
Const TheRow = 2
Const FirstCol = 2 ' column B
Const ExtraString = "@domain.com"
Dim LastCol As Long
Dim TheCol As Long
Application.ScreenUpdating = False
LastCol = Cells(TheRow, Columns.Count).End(xlToLeft).Column
For TheCol = FirstCol To LastCol
With Cells(TheRow, TheCol)
If InStr(.Value, "@") = 0 Then
.Value = .Value & ExtraString
End If
End With
Next TheCol
Application.ScreenUpdating = True
End Sub