Macro to merge and format selected cell

T

Taylor

I want to create a macro that will merge the selected cell with the one next
to it (on the right) and format it to align left. When this macro runs, I
would like for it to perform the action in whichever cell is selected and not
the cells that are referenced while recording the macro. I hope this makes
sense!
 
P

Pete Rooney

Taylor,

How about:

Sub MergeCells()
With Selection
.Resize(1, 2).MergeCells = True
.Resize(1, 2).HorizontalAlignment = xlLeft
End With
End Sub

regards

Pete
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top