Merge Macro - HELP!

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,970
Office Version
  1. 2010
Platform
  1. Windows
Hi Guys,

I need some help!

I need a macro which will look in column A:A for “Grand Total”, when found, merge the cells of the row which contain “Grand Total” across A:D, then colour the interior of the cells Grey, bold in white and right align

Can anyone please help?

TIA
 

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.
Is Grnad total always in the same cell, if so why not use the macro recorder to do all the above...the code can then be tidied up a little?
 
Upvote 0
First you can get the formmating by Recording a Macro So that part is not important. What we do need is how you want the information itself spaced/formatted, you need to post a sample of what is in A:D now and what you want [Which Cell?] to contain after the macro runs!


In Cell "A:" Grand Total: Cell B, Cell C, Cell D

or what?


Try this as a starting point:


Sub myGrandTot()
'Standard module code, like: Modul1.
Dim lngMyBotR&
Dim objMyRng As Object, Cell As Object

lngMyBotR = ActiveSheet.Range("A65536").End(xlUp).Row
Set objMyRng = ActiveSheet.Range("A1:A" & lngMyBotR)

For Each Cell In objMyRng

If UCase(Left(Cell.Value, 5)) = "GRAND" Then
Cell.Value = Cell.Value & ": " & Cell.Offset(0, 1).Value & ", " & _
Cell.Offset(0, 2).Value & ", " & _
Cell.Offset(0, 3).Value
End If

Next Cell
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,899
Messages
6,122,155
Members
449,068
Latest member
shiz11713

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