|
関数にこだわってたんで、だんだんマクロの必要性に疑問が....。
手作業で関数を書き込んでフィルドラッグで十分な気もしてきました。
Sub ドレミ天国()
Dim MRo As Variant, ERo As Long, KKS As String
Dim KS1 As String, KS2 As String, KS3 As String, KS4 As String
MRo = Application.Match("No1", Rows(1), 0)
If IsError(MRo) Then MsgBox "No1がありません。": End
ERo = ActiveSheet.UsedRange.Cells(ActiveSheet.UsedRange.Count).Row
KS1 = "=RC[1]&IF(RC[2]="""","""",IF(AND(COUNTA(RC[1]:RC[1])>0,RC[2]<>""""),CHAR(10),"""")"
KS2 = "&RC[2])&IF(AND(COUNTA(RC[1]:RC[2])>0,RC[3]<>""""),CHAR(10),"""")"
KS3 = "&RC[3]&IF(AND(COUNTA(RC[1]:RC[3])>0,RC[4]<>""""),CHAR(10),"""")&RC[4]"
KS4 = "&IF(AND(COUNTA(RC[1]:RC[4])>0,RC[5]<>""""),CHAR(10),"""")&RC[5]"
KKS = KS1 & KS2 & KS3 & KS4
With Range(Cells(2, MRo - 1), Cells(ERo, MRo - 1))
.VerticalAlignment = xlTop
.WrapText = True
.FormulaR1C1 = KKS
.Rows.AutoFit
End With
End Sub
|
|