[Excel VBA] 문자열 합치기
목적
: 다양한 문자열 들을 합치는 기능 구현
ex) A 와 B 라는 양식의 글들을 있을때 A(B) 라는 문자열로 모두 만들때
실행 결과
: B~차있는 열 까지의 문자들이 모두 합쳐져서 A 열에 나타나게 됨
코드
Sub sum_string() Dim template_sht As Worksheet, position_sht As Worksheet, std_job_sht As Worksheet
Set template_sht = Sheets("Data") '실제 Sheet 의 이름 Dim template_row As Integer, template_col As Integer Dim temp_str As String Dim i As Integer, j As Integer
template_row = template_sht.UsedRange.Rows.count template_col = template_sht.UsedRange.Columns.count For i = 1 To template_row
temp_str = "" For j = 2 To template_col If IsEmpty(template_sht.Rows(i).Columns(j).Value) Then Else temp_str = temp_str & template_sht.Rows(i).Columns(j).Value End If Next j template_sht.Rows(i).Columns(1).Value = temp_str Next i
End Sub |