Need help with convert VBA code to another file

Occasional Contributor

I'm using office 365 with İntel Mac.

 

I was seeking an answer for my problem. @Quadruple_Pawn gave me this useful solution below which is works very well. Attached image 'solution'. This code's purpose is to print if there is a 'True' in A column, it should print the corresponding part in D column in order to column C. The problem is old file was an example file and now I got the original data DataLO.xlsx and I couldn't succeed to convert this code to make it work with this original file. Because at some point the rows format is changing in file(see attached other image) and I don't know how to convert this code to complete this task. Also in original data we have additionally id in column A, true-false values are separated with rows and I need to add new column to print opt-in as the previous file(attached file LO data testing(1).xlsm). 

 

Any idea?

 

Option Explicit

 

Function SelItems(rng1, rng2) As String

Const sep = vbLf

Dim a1() As String

Dim a2() As String

Dim i As Long

Dim j As Long

Dim s As String

a1 = Split(rng1, vbLf)

a2 = Split(rng2, ",")

For i = UBound(a1) - 5 To UBound(a1)

If a1(i) = "True" Then

s = s & "," & a2(j)

j = j + 1

Else

j = j + 1

End If

Next i

If s <> "" Then

SelItems = Mid(s, Len(sep) + 1)

End If

End Function

0 Replies