vba to locate bottom of data and merge adjacent cells

cjcass

Well-known Member
Joined
Oct 27, 2011
Messages
683
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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
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,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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