A few things:
Re:"I am getting error in it." and "But I got error while running."
Saying what error would be very helpful.
Re:"I put a MsgBox in the code to catch the value. But it didn't show
anything."
This happens when there is nothing in the cell. Cells(7,2) refers to
cell 7 rows down and 2 columns across, ie. B7.
As your code stands it tries to add (not concatenate) the following 4
things:
what it finds in row 7, "Y", what it finds in row 8, "M"
and it looks to row 2 to see how many columns it should process (I
imagine these are headers?). So as long as there's something in the
column in row 2 it tries to do the concatenating. When it reaches the
first empty cell in row 2 it stops looping.
Now all you need to do is change every instance of a '+' sign in the
code to a '&'. This should stop the Type mismatch error.
Cells(9, y).Value = Cells(7, y).Value & "Y" & Cells(8, y).Value & "M"
I note also that you have the line
x = 7
but never use x elsewhere.