I have data written in Cells B5, C5, D5 etc that changes as you add more column data
I am trying to figure out how to merge cells starting from Cell B3 based on used cells in row B5 to end of column.
I have data written in Cells B5, C5, D5 etc that changes as you add more column data
I am trying to figure out how to merge cells starting from Cell B3 based on used cells in row B5 to end of column.
Re: Merge Cells based on used cells in column 5
No idea what you mean...
Please upload a sample workbook showing before and after.
On another tack, why would you want to merge cells? It makes it nearly impossible to manipulate the data.
Re: Merge Cells based on used cells in column 5
Please see the attached sample sheet
In row 7 there are Zones mentioned from Zon1 to to Zone 5
Now the merged cells should be C4:G4
When new Zones are added for Eg. Zone 6 and Zone 7 in col. H and I
then the merged cells should be C4:I4
Re: Merge Cells based on used cells in column 5
There's no attachment.
However, I would not ignore Cytop's advice on merging cells, quite simply - don't!
Re: Merge Cells based on used cells in column 5
I had forgotten the attachment and then edited the post to attach the sample sheet.
Project requires megring to give a neat presentation.
Re: Merge Cells based on used cells in column 5
Try
Private Sub Worksheet_Change(ByVal Target As Range)
Dim iCount As Integer
If Not Intersect(Range("C7:I7"), Target) Is Nothing Then
iCount = Application.WorksheetFunction.CountA(Range("C7:I7"))
Range("C4:I7").HorizontalAlignment = xlGeneral
Range("C4").Resize(, iCount).HorizontalAlignment = xlCenterAcrossSelection
End If
End Sub
Display More
But note that if the selection is too narrow (2 or 3 cells only) then the text will offset to the left so it centers over the existing text... This can be avoided by other formatting like row height and word wrap.
Don’t have an account yet? Register yourself now and be a part of our community!