Macro to merge and format selected cell
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! |
Macro to merge and format selected cell
Taylor,
How about: Sub MergeCells() With Selection .Resize(1, 2).MergeCells = True .Resize(1, 2).HorizontalAlignment = xlLeft End With End Sub regards Pete "Taylor" wrote: 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! |
Macro to merge and format selected cell
Just what I needed! Thanks for such a speedy response!
"Pete Rooney" wrote: Taylor, How about: Sub MergeCells() With Selection .Resize(1, 2).MergeCells = True .Resize(1, 2).HorizontalAlignment = xlLeft End With End Sub regards Pete "Taylor" wrote: 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! |
Macro to merge and format selected cell
You're welcome! :-)
Pete "Taylor" wrote: Just what I needed! Thanks for such a speedy response! "Pete Rooney" wrote: Taylor, How about: Sub MergeCells() With Selection .Resize(1, 2).MergeCells = True .Resize(1, 2).HorizontalAlignment = xlLeft End With End Sub regards Pete "Taylor" wrote: 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! |
All times are GMT +1. The time now is 11:24 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com