0

I've checked all the answers in stackoverflow about merging cells in excel using macro, but I'm having a hard time understanding the codes.

Description: I want to MERGE the two cells which contains "Lastname" and "Firstname" into one cell in row 3.

Thanks for helping guys.

1 Answer 1

1

With data like:

enter image description here

Running this macro:

Sub MerThem()
    Set r = Range("3:3").Find(what:="Lastname", After:=Range("3:3")(1))

    v = r.Value & r.Offset(0, 1).Value
    r.Clear
    r.Offset(0, 1).Clear
    Range(r, r.Offset(0, 1)).MergeCells = True
    r.Value = v
End Sub

Will produce:

enter image description here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.