This function will put your structure in cell C with value of column A
Use it like : =mytracks(A2)
Setup of the cells : you need to allow the text to flow to another line.
If you want to use result, you need to paste as only text in D for example
CharlizeFunction mytracks(mycd As Range) As String Dim mywb As Workbook, mywstracks As Worksheet Dim mytrackno As String, notracks As Long Dim looptracks As Long Set mywb = ActiveWorkbook Set mywstracks = mywb.Worksheets("TRACKS") mytrackno = mycd.Value notracks = mywstracks.Range("A" & Rows.Count).End(xlUp).Row mytracks = "<table>" & Chr(10) & "<tbody>" & Chr(10) If mytrackno = vbNullString Then mytracks = "no ID specified ..." Exit Function Else For looptracks = 2 To notracks If mytrackno = mywstracks.Cells(looptracks, 1) Then mytracks = mytracks & "<tr>" & Chr(10) & "<td>" & mywstracks.Cells(looptracks, 2) & "</td>" & _ Chr(10) & "<td>" & mywstracks.Cells(looptracks, 3) & "</td>" & Chr(10) & "</tr>" & Chr(10) End If Next looptracks End If mytracks = mytracks & "</tbody>" & Chr(10) & "</table>" End Function




Reply With Quote