+ Reply to Thread
Results 1 to 18 of 18

Compare JSON data and splitting into corrected codes, deleted codes and added codes

Hybrid View

  1. #1
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,834

    Re: Compare JSON data and splitting into corrected codes, deleted codes and added codes

    What is the definition of "correctedcode"?

    Try replace "Private Sub GetDetails" with following code and see how it goes.
    Private Sub GetDetails(ByVal txt As String, myKey, dic As Object, flg As Boolean)
        Dim m As Object, e
        With CreateObject("VBScript.RegExp")
            .Global = True
            .Pattern = """description"": *""(.+?)"".*[\r\n]+.*""dCode"": *""(.+?)"""
            For Each m In .Execute(txt)
                If flg Then
                    dic(myKey)(m.submatches(0)) = m.submatches(1)
                Else
                    If dic(myKey).exists(m.submatches(0)) Then
                        If dic(myKey)(m.submatches(0)) <> m.submatches(1) Then
                            dic(myKey)("correctedcode") = dic(myKey)("correctedcode") & _
                            IIf(dic(myKey)("correctedcode") <> "", ", ", "") & dic(myKey)(m.submatches(0))
                        End If
                        dic(myKey).Remove m.submatches(0)
                    Else
                        dic(myKey)("addedcode") = m.submatches(1)
                    End If
                End If
            Next
        End With
        If Not flg Then
            For Each e In dic(myKey)
                Select Case e
                    Case "Billid", "Ctextid", "codername", "correctedcode", "addedcode", "deletedcode"
                    Case Else
                        dic(myKey)("deletedcode") = dic(myKey)("deletedcode") & _
                        IIf(dic(myKey)("deletedcode") <> "", ", ", "") & dic(myKey)(e)
                End Select
            Next
        End If
    End Sub
    Last edited by jindon; 12-01-2020 at 03:27 AM.

  2. #2
    Forum Contributor
    Join Date
    10-18-2016
    Location
    Chicago, USA
    MS-Off Ver
    Office 365
    Posts
    220

    Re: Compare JSON data and splitting into corrected codes, deleted codes and added codes

    @ Jindon: The corrected code is basically which codes have been overwritten (meaning replaced by other codes)...Now this can be included with the deleted codes.. The corrected codes can be done away with as the deleted codes and added codes gives the information on what codes changes have happened ...So with the latest code the output I am getting for Billid 7789 and ctextid 60045 for deleted code is U8923, Y98620 which is partially correct but the corrected codes also need to be included Z003345, H678...So the entire set of deleted codes should be Z003345,H678,U8923,Y98620 ..The corrected code column can be done away with or deleted..

    Really appreciate your help!..

    Thanks,
    Arun

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Compare JSON data and splitting into corrected codes, deleted codes and added codes
    By chandramouliarun in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 11-29-2020, 12:06 PM
  2. Added codes to macro and some codes no longer work
    By alisoncleverly in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-14-2020, 01:26 PM
  3. [SOLVED] Convert Y Codes from one column to another based on Unique Codes
    By ashishmehra2010 in forum Excel General
    Replies: 2
    Last Post: 10-06-2015, 09:49 PM
  4. Replies: 7
    Last Post: 08-13-2015, 10:58 AM
  5. Replies: 1
    Last Post: 12-10-2013, 12:28 AM
  6. Replies: 0
    Last Post: 10-09-2013, 07:59 PM
  7. Combining vba codes makes the previous codes broken !
    By MDPLUS in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-26-2013, 10:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1