회사 생활/칼퇴를 도와주는 엑셀 꿀팁
Special Merge
Power platform
2020. 6. 28. 17:37
반응형
엑셀에서 셀을 병합하면 한셀에 있는 데이터만 남고 지워집니다. 하지만 다음 코드를 실행하면 다른행의 데이터도 그대로 남기고 행이 병합됩니다.
[VBA 코드]
Sub SpecialMerge()
Dim output As String
Dim inputrange As Variant
Const space = " "
On Error Resume Next
For Each cell In Selection
output = output & cell.Value & space
Next cell
With Selection
.Clear
.Cells(1).Value = output
.Merge
.HorizontalAlignment = xlGeneral
.VerticalAlignment = xlCenter
.WrapText = True
End With
End Sub
반응형