Public Sub test()
Application.ScreenUpdating = False
Dim b As Long
Cells.Clear
ActiveWindow.DisplayGridlines = False
R1 = "#, Desc , Desc2 , Refrenace No. ,Desc,Rev0,,,,Rev1,,,,Rev2,,,,Rev3,,,,Rev4,,,,Rev5,,,,Remarks"
R2 = ",,,,,Date Sub, Date Rec , Days ,Code,Date Sub,Date Rec,Days,Code,Date Sub,Date Rec,Days,Code,Date Sub,Date Rec,Days,Code,Date Sub,Date Rec,Days,Code,Date Sub,Date Rec,Days,Code,"
R3 = "1,dsdfdsf,sfdsf,xx-xx-xx-00001,ar,01-jan-19,05-jan-19,4,C,07-jan-19,10-jan-19,3,C,12-Jan-19,15-jan-19,3,B,,,,,,,,,,,,,"
R4 = "2,hjhjhgj,vcvbcvb,xx-xx-xx-00002,ar,01-jan-19,10-Jan-19,9,C,12-Jan-19,15-Jan-19,3,C,16-jan-19,20-jan-19,4,C,21-Jn-19,25-Jn-19,4,B,,,,,,,,,"
TR = R1 & ";" & R2 & ";" & R3 & ";" & R4
For R = 2 To 5
For c = 1 To 30
With Cells(R, c)
If R = 2 And (c <= 5 Or c = 30) Then .Resize(2, 1).Merge
If R = 2 And (c = 6 Or c = 10 Or c = 14 Or c = 18 Or c = 22 Or c = 26) Then .Resize(1, 4).Merge
.Value = Split(Split(TR, ";")(R - 2), ",")(c - 1)
End With
Next
Next
Cells.EntireColumn.AutoFit
'COLOR
With Cells(2, 1).Resize(2, 30)
With .Interior
.Pattern = xlSolid
.Color = RGB(253, 233, 217)
End With
End With
'Borders
With Cells(2, 1).Resize(5, 30)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
For b = 7 To 12
With .Borders(b)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlHairline
End With
Next
End With
[B8] = "=CONCATENATE(SUBSTITUTE(IF(F4<>"""",""*""&CONCATENATE(""Rev0"","","",TEXT(F4,""dd-mmm-yy""),"","",TEXT(G4,""dd-mmm-yy""),"","",H4,"","",I4)&"";"","""")&IF(J4<>"""",""*""&CONCATENATE(""Rev1"","","",TEXT(J4,""dd-mmm-yy""),"","",TEXT(K4,""dd-mmm-yy""),"","",L4,"","",M4)&"";"","""") &IF(N4<>"""",""*""&CONCATENATE(""Rev2"","","",TEXT(N4,""dd-mmm-yy""),"","",TEXT(O4,""dd-mmm-yy""),"","",P4,"","",Q4)&"";"","""")&IF(R4<>"""",""*""&CONCATENATE(""Rev3"","","",TEXT(R4,""dd-mmm-yy""),"","",TEXT(S4,""dd-mmm-yy""),"","",T4,"","",U4)&"";"","""") &IF(V4<>"""",""*""&CONCATENATE(""Rev4"","","",TEXT(V4,""dd-mmm-yy""),"","",TEXT(W4,""dd-mmm-yy""),"","",X4,"","",Y4)&"";"","""")&IF(Z4<>"""",""*""&CONCATENATE(""Rev5"","","",TEXT(Z4,""dd-mmm-yy""),"","",TEXT(AA4,""dd-mmm-yy""),"","",AB4,"","",AC4)&"";"",""""),""*"",CONCATENATE(B4,"","",C4,"","",D4,"","",E4)&"","")" & _
",SUBSTITUTE(IF(F5<>"""",""*""&CONCATENATE(""Rev0"","","",TEXT(F5,""dd-mmm-yy""),"","",TEXT(G5,""dd-mmm-yy""),"","",H5,"","",I5)&"";"","""")&IF(J5<>"""",""*""&CONCATENATE(""Rev1"","","",TEXT(J5,""dd-mmm-yy""),"","",TEXT(K5,""dd-mmm-yy""),"","",L5,"","",M5)&"";"","""") &IF(N5<>"""",""*""&CONCATENATE(""Rev2"","","",TEXT(N5,""dd-mmm-yy""),"","",TEXT(O5,""dd-mmm-yy""),"","",P5,"","",Q5)&"";"","""")&IF(R5<>"""",""*""&CONCATENATE(""Rev3"","","",TEXT(R5,""dd-mmm-yy""),"","",TEXT(S5,""dd-mmm-yy""),"","",T5,"","",U5)&"";"","""") &IF(V5<>"""",""*""&CONCATENATE(""Rev4"","","",TEXT(V5,""dd-mmm-yy""),"","",TEXT(W5,""dd-mmm-yy""),"","",X5,"","",Y5)&"";"","""")&IF(Z5<>"""",""*""&CONCATENATE(""Rev5"","","",TEXT(Z5,""dd-mmm-yy""),"","",TEXT(AA5,""dd-mmm-yy""),"","",AB5,"","",AC5)&"";"",""""),""*"",CONCATENATE(B5,"","",C5,"","",D5,"","",E5)&"",""))"
For R = 9 To 20
For c = 1 To 30
With Cells(R, c)
' If c = 7 Then .Resize(1, 2).Merge, Merge cell to fit contents not function
End With
Next
Next
''''''''''''''''''''''''''''''''''''''''''''
On Error Resume Next ' may it Long not work
Range("B10:L40").FormulaArray = "=TRIM(MID(SUBSTITUTE(IFERROR(MID(B$8,FIND(""|"",SUBSTITUTE("";""&B$8&"";"","";"",""|"",(ROW()-ROW(B$10)+1))),FIND("";"",B$8&"";"",FIND(""|"",SUBSTITUTE("";""&B$8&"";"","";"",""|"",(ROW()-ROW(B$10)+1))))-FIND(""|"",SUBSTITUTE("";""&B$8&"";"","";"",""|"",(ROW()-ROW(B$10)+1)))),""""),"","",REPT("" "",99)),(COLUMN()-COLUMN(B$10)+1)*99-98,99))"
On Error GoTo 0
'''''''''''''''''''' workwill
Range("B10:L20").FormulaArray = "=TRIM(MID(SUBSTITUTE(TRIM(MID(SUBSTITUTE(B8,"";"",REPT("" "",999)),(ROW()-ROW(B$10)+1)*999-998,999)),"","",REPT("" "",999)),(COLUMN()-COLUMN(B$10)+1)*999-998,999))"
'COLOR
With Cells(9, 1).Resize(1, 11)
With .Interior
.Pattern = xlSolid
.Color = RGB(253, 233, 217)
End With
End With
'Borders
With Cells(9, 1).Resize(15, 11)
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
For b = 7 To 12
With .Borders(b)
.LineStyle = xlContinuous
.ColorIndex = 0
.TintAndShade = 0
.Weight = xlHairline
End With
Next
End With
Application.ScreenUpdating = False
End Sub