Forum Discussion

Sjefferson2118's avatar
Sjefferson2118
Copper Contributor
Oct 26, 2023

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 @emailaddress.com to the end of them. I do not want to create a new row that has the usernames+@emailaddress I would ideally like to add the @emailaddress.com to the end of the usernames in the row that already exists

  • Sjefferson2118 

    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

Resources