Excel VBA Merging Cells

KitK369

New Member
Joined
Aug 27, 2018
Messages
14
Yes, I'm aware that merging cells in VBA is not recommended and often a nightmare, however it's a necessity for the workbook I'm working on. Please feel free to slap my hand for merging though haha.

I'm looking to merge two cells in a column. It needs to be activecell based and not based on Cell A15:A16. I have found tons of data on merging cells across columns but not across rows. For example, I am using an ActiveCell Offset function to return to cell A15 (this cell can vary depending on the worksheet so that's why I'm using an offset function.) I need to then merge and center cells A15 and A16 (but keep in mind these cells change depending on the worksheet and I need the macro to be fluid.)

Any chance anyone can point me in the right direction of how to accomplish this?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
so you want to merge Active cell with the cell below it? If I understood you correctly, try this code

Code:
Sub MergeCells()
    Range(ActiveCell.Address & ":" & ActiveCell.Offset(1).Address).Merge
End Sub
 
Upvote 0
Alternatively
Code:
ActiveCell.Resize(2).Merge
 
Upvote 0
Glad we could help & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top