Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6618773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:52:48+00:00 2026-05-25T20:52:48+00:00

I am trying to do below example, not able to do it. Excel Data

  • 0

I am trying to do below example, not able to do it.

Excel Data in Sheet1:

id     Sysid     option      status
XYZ      XT       Open       status_1
US     XT       Close      Status_1
US      XT       Open       Stauts_2
NJ      XT       Open   Status_2
IND     VX       Close      Status_1
BAN     VX       Open       Status_1
CHN     XY       Open       Status_1
YST     xy       Close      Status_1

In above data Status_1 and Sysid defines unique record,Based on this condition i have to find out which records have open and close difference for that unique record combination. If options are different I have to copy that data to different sheet using excel macro.This should work only for id’s US and CHN.Suppose if id has US ,it should compare with matching record based on sysid and Status. Any help appreciated.

Output Like below:

 XYZ      XT       Open       status_1
 US     XT       Close      Status_1
 CHN     XY       Open       Status_1
 YST     xy       Close      Status_1
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T20:52:49+00:00Added an answer on May 25, 2026 at 8:52 pm

    Edited to include test for “US” or “CHN”

    Sub Tester()
    
    Const COL_ID As Integer = 1
    Const COL_SYSID As Integer = 2
    Const COL_STATUS As Integer = 4
    Const COL_OPTION As Integer = 3
    Const VAL_DIFF As String = "XXdifferentXX"
    
    Dim d As Object, sKey As String, id As String
    Dim rw As Range, opt As String, rngData As Range
    Dim rngCopy As Range, goodId As Boolean
    Dim FirstPass As Boolean, arr
    
        With Sheet1.Range("A1")
            Set rngData = .CurrentRegion.Offset(1).Resize( _
                             .CurrentRegion.Rows.Count - 1)
        End With
        Set rngCopy = Sheet1.Range("F2")
    
        Set d = CreateObject("scripting.dictionary")
        FirstPass = True
    
    redo:
        For Each rw In rngData.Rows
    
            sKey = rw.Cells(COL_SYSID).Value & "<>" & _
                   rw.Cells(COL_STATUS).Value
    
            If FirstPass Then
              'Figure out which combinations have different option values
              '  and at least one record with id=US or CHN
              id = rw.Cells(COL_ID).Value
              goodId = (id = "US" Or id = "CHN")
              opt = rw.Cells(COL_OPTION).Value
    
              If d.exists(sKey) Then
                  arr = d(sKey) 'can't modify the array in situ...
                  If arr(0) <> opt Then arr(0) = VAL_DIFF
                  If goodId Then arr(1) = True
                  d(sKey) = arr 'return [modified] array
              Else
                  d.Add sKey, Array(opt, goodId)
              End If
    
            Else
              'Second pass - copy only rows with varying options
              '  and id=US or CHN
              If d(sKey)(0) = VAL_DIFF And d(sKey)(1) = True Then
                  rw.Copy rngCopy
                  Set rngCopy = rngCopy.Offset(1, 0)
              End If
            End If
    
        Next rw
        If FirstPass Then
            FirstPass = False
            GoTo redo
        End If
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In the example below I'm trying to access the parents sibling. Is there a
I'm trying to perform a group by action on an aliased column (example below)
Below I have a very simple example of what I'm trying to do. I
I'm trying to call the SQL statement below but get the following error: System.Data.SqlClient.SqlException:
I am trying to learn the MVC architecture. But I am not able to
EDIT: Changed example below to one that actually demonstrates the SIOF. I am trying
After trying all the methods in the previous post I am not able to
In the code below i`m trying to read a list of selected projects and
Below is my code which I am trying to find 'Username Ok' in the
The code below is what I am trying to use in order to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.