vba to locate bottom of data and merge adjacent cells

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
680
Office Version
  1. 2016
Platform
  1. Windows
Hi,
Is there some vba that will look down a column of data, find the last three entries and then merge three adjacent cells, type in the word BOTTOM, rotate the text up, centralise the text in both planes, and finally fill it red with red text? Please assume the column of data has a fixed range, eg. in the first example the data range runs from B3:B30.
Please see the examples of the required result below...
Any help much appreciated.
2nw0dw1.jpg
 

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
ok, looks like I've found a solution from a previous post on Mr.Excel, the code is as follows (ignoring my specific examples):
Thanks to anyone who was working on this for me :)

Sub mergeAlike()
Application.DisplayAlerts = False
Set rng = ActiveSheet.Range("B1:B30")
x = 1
y = 1
Do
Do While rng.Cells(x, 1) = rng.Cells(y, 1)
x = x + 1
Loop
If x - y > 2 Then
Range(rng.Cells(x - 1, 1), rng.Cells(y, 1)).Merge
End If
y = x
Loop Until y > rng.Cells.Count
Application.DisplayAlerts = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,216,438
Messages
6,130,632
Members
449,584
Latest member
c_clark

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