Jimmy Huang
Jimmy Huang

Reputation: 49

Excel vba how to merge this three cells?

I try to merge three cells, and assign it to other cells, but it fails to merge third cell. Below is my code,

For x = 2 To LastRow_Line_Site
        With Sheets("Line_Site")
            .Cells(x, "E") = CStr(.Cells(x, "A") & .Cells(x, "B") & .Cells(x, "C"))
        End With
    Next

ColA:8009601022 ColB:77854 ColC:00340, and I expect to have the result like 80096010227785400340, but it turns out become 80096010227785400000

Could anyone help me on this issues?

Many thanks!!

Upvotes: 0

Views: 60

Answers (1)

user3598756
user3598756

Reputation: 29421

    With Sheets("Line_Site")
        .Cells(x, "E").NumberFormat = "@"
        .Cells(x, "E") = .Cells(x, "A").Text & .Cells(x, "B").Text & .Cells(x, "C").Text
    End With

Upvotes: 5

Related Questions