jasonwills
New Member
Hi All,
i have come across this VBA from someone elses post, and it is very near what i am after.
[pre]
[/pre]
however, what i'd like to be able to do is to select a whole load of rows at one, and have the macro merge each line separately, rather than into 1 large cell.
so if i select cells A1:C3, it will merge A1:3 and B1:3 and C1:3 etc.
and just to add one other thing, i'd also like to apply the macro only if the cell contains a certain word.
any help / pointers is greatly appreciated.
Regards
Jason
i have come across this VBA from someone elses post, and it is very near what i am after.
[pre]
Code:
Sub JoinAndMerge2()
Const Delimiter = " "
On Error Resume Next
With Selection
If Selection.Rows.Count > 1 Then
.Item(1).Value = Join(WorksheetFunction.Transpose(Selection), Delimiter)
.Item(2).Resize(Selection.Count–1).Clear
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
Else
.Item(1).Value = Join(WorksheetFunction.Index(Selection.Value, 1, 0), Delimiter)
.Item(2).Resize(1, Selection.Count–1).Clear
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlGeneral
End If
.Merge
.WrapText = True
End With
End Sub
however, what i'd like to be able to do is to select a whole load of rows at one, and have the macro merge each line separately, rather than into 1 large cell.
so if i select cells A1:C3, it will merge A1:3 and B1:3 and C1:3 etc.
and just to add one other thing, i'd also like to apply the macro only if the cell contains a certain word.
any help / pointers is greatly appreciated.
Regards
Jason