Reverse Comma Delimited

dianamruelas

New Member
Joined
Sep 28, 2015
Messages
44
Office Version
  1. 365
Platform
  1. Windows
I receive a healthcare financial report. Each account has several services called "CPT." Each CPT has an assigned payment code called "EOB Code." The report I get lists all EOB codes for the account next to each CPT. I would like to break this down to only list the EOB code applicable to each CPT. This can be identified by the "EOB Code Number." The EOB Code Number corresponds with the actual EOB code. For the example below, CPT 99214 has EOB Code Number 2. "2-3" identifies the specific EOB Code assigned to the CPT, so the CPT Code I want is "3." For CPT 27392, I need "59."

AccountCPTEOB Code NumberAccount EOB Codes
543219921422-3,3-59,4-288,5-N630,6-288,7-N630
543212739232-3,3-59,4-288,5-N630,6-288,7-N630
54321868724,52-3,3-59,4-288,5-N630,6-288,7-N630
54321868316,72-3,3-59,4-288,5-N630,6-288,7-N630

<tbody>
</tbody>


Here is the needed format. It can be comma delimited or listed out separately, but I prefer comma delimited.

AccountCPTsEOB Codes
54321992143
543212739259
5432186872288,N630
5432186831288,N630

<tbody>
</tbody>

OR

AccountCPTEOB Codes
54321992143
543212739259
5432186872288
5432186872N630
5432186831288
5432186831N630

<tbody>
</tbody>
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
How about
Code:
Sub SortData()
   Dim Cl As Range
   Dim Sp1 As Variant, Sp2 As Variant, x As Variant
   Dim i As Long
   
   For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
      Sp1 = Split(Cl.Value, ",")
      Sp2 = Split(Cl.Offset(, 1).Value, ",")
      For i = 0 To UBound(Sp1)
         If x = "" Then x = Split(Sp2(Sp1(i) - 2), "-")(1) Else x = x & "," & Split(Sp2(Sp1(i) - 2), "-")(1)
      Next i
      Cl.Value = x
      Cl.Offset(, 1).ClearContents
      x = ""
   Next Cl
End Sub
 
Upvote 0
Thank you!!! This is great. But the data will vary. I added to the first line. Please see the error I get when running it on the below:

InvoiceCPTEOB Code NumberEOB Codes
P54321992141,21-45,2-3,3-59,4-288,5-N630,6-288,7-N630
P543212739232-3,3-59,4-288,5-N630,6-288,7-N630
P54321868724,52-3,3-59,4-288,5-N630,6-288,7-N630
P54321868316,72-3,3-59,4-288,5-N630,6-288,7-N630

<colgroup><col span="2"><col><col></colgroup><tbody>
</tbody>
 
Upvote 0
And there can actually be up to several dozen codes. Can that be accounted for?
 
Upvote 0
How about
Code:
Sub SortData()
   Dim Cl As Range
   Dim Sp1 As Variant, Sp2 As Variant, x As Variant, a As Variant
   Dim i As Long
   
   For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
      Sp1 = Split(Cl.Value, ",")
      Sp2 = Split(Cl.Offset(, 1).Value, ",")
      For i = 0 To UBound(Sp1)
         a = Application.Match(Sp1(i) & "*", Sp2, 0)
         If Not IsError(a) Then
            If x = "" Then x = Split(Sp2(a - 1), "-")(1) Else x = x & "," & Split(Sp2(a - 1), "-")(1)
         End If
      Next i
      Cl.Value = x
      Cl.Offset(, 1).ClearContents
      x = ""
   Next Cl
End Sub
 
Upvote 0
And there can actually be up to several dozen codes. Can that be accounted for?

A UDF solution - First parameter, Codes, is the cellcontaining EOB Code Number. Secondparameter , CodeList, is the cell containing Account EOB Codes.


Rich (BB code):
Function EOBCode(Codes, CodeList)
    
    C = Split(Codes, ",")
    CL = Split(CodeList, ",")
    For i = 0 To UBound(C)
        found = False
        For j = 0 To UBound(CL)
            CLparts = Split(CL(j), "-")
            If CLparts(0) = C(i) Then
                EOBCode = EOBCode & CLparts(1) & ","
                found = True
                Exit For
            End If
        Next
        If Not found Then EOBCode = EOBCode & "#NA" & ","
    Next
    EOBCode = Left(EOBCode, Len(EOBCode) - 1)
Rich (BB code):
Rich (BB code):
End Function


 
Upvote 0
Last thing. I'm pretty amateur. The Sub works perfectly. But I cut the columns out of my actual report as not to be overwhelming in my original post. Now I'm afraid I'll mess it up by trying to adapt it to the report, which has 21 columns. Here's a mock of the report, could you please adjust to the correct columns? I've highlighted the original 4 columns with red font. Column C from above is now column U

Account #PatientSubscriber #DOBBilling ProviderBilling Provider TypeBilling Prov NPIService DateCPTModEOB Allowed AmountExpected Allowed AmountAllowed Amount Discrepancy% of Expected AllowedDiscrepancy %Patient LiabilityPaid AmountEOB Code NumberEOB Codes
P54321Mr. SmithW099233166 10/25/58Dr. SmithPhysician1396705919 10/01/1899214113.41122.489.0792.59%7.41%0.00113.411,21-45,2-3,3-59,4-288,5-N630,6-288,7-N630
P54321Mr. SmithW099233166 10/25/58Dr. SmithPhysician1396705919 10/01/182739220.0321.631.6092.60%7.40%0.0020.0331-45,2-3,3-59,4-288,5-N630,6-288,7-N631
P54321Mr. SmithW221226798 03/26/03Dr. SmithPhysician1427035484 10/01/188687218.7720.271.5092.60%7.40%0.0018.774,51-45,2-3,3-59,4-288,5-N630,6-288,7-N632
P54321Mr. SmithW211213062 03/13/63Dr. SmithPhysician1588806749 10/01/1886831130.76150.1419.3887.09%12.91%130.760.006,71-45,2-3,3-59,4-288,5-N630,6-288,7-N633

<tbody>
</tbody>
 
Upvote 0
Just change the range from C to U on this line
Code:
   For Each Cl In Range("C2", Range("C" & Rows.Count).End(xlUp))
 
Upvote 0
I'm getting an error. Do I replace all "C" with "U"? Or just in that one line? And correction, it is actually column "S," not "U."
 
Upvote 0
Just replace both "C"s in that line
 
Upvote 0

Forum statistics

Threads
1,215,475
Messages
6,125,028
Members
449,205
Latest member
Eggy66

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top