Merge Macro - HELP!

MarkAndrews

Well-known Member
Joined
May 2, 2006
Messages
1,963
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

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number

ADAMC

Well-known Member
Joined
Mar 20, 2007
Messages
1,169
Office Version
  1. 2013
Platform
  1. Windows
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?
 

Joe Was

MrExcel MVP
Joined
Feb 19, 2002
Messages
7,539
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
 

Forum statistics

Threads
1,181,734
Messages
5,931,731
Members
436,800
Latest member
abowalid98

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
Top