Creating link between different columns

bulletcss

New Member
Joined
Oct 29, 2022
Messages
12
Office Version
  1. 2019
Platform
  1. Windows
Hi there.

I have a problem I need to tackle.

There is a table that consists of three columns. Two highlighted are loaded from a source file. The third column is entered by user manually.
But sometimes the arrangement of rows in the source file is changed. So after that, the third column corresponds to the data wrongly.

I tried to illustrate that. It can be seen that the pairing for "Elem4" and "Elem6" are broken after shuffling on the right table.

Illustration.png


So, my question is how to "link" the values in columns 1 and 2 to values from column 3 to make them "move together"?

The only solution I found is creating an extra sheet to store data pairs there and parse third column values with INDEX and MATCH.
Is there a more elegant solution to this problem?
 
in fact, i was storing info that was not needed.

VBA Code:
Private Sub Workbook_Open()

'this assumes column 1 is column b, 2 is column c,3 is column d, change to suit your data

Application.Calculation = xlManual
    lr = Range("A" & Rows.Count).End(xlUp).Row
    ReDim B(1 To lr) As String
    ReDim D(1 To lr) As String
   
    'store the options
    For RW = 2 To lr
        If Range("D" & RW) <> "" Then
            B(RW) = Range("B" & RW)
            D(RW) = Range("D" & RW)
        End If
    Next RW
   
    Application.Calculation = xlAutomatic
    Application.Calculate
   
    're-apply the options
    Range("D2:D" & lr).ClearContents
    For RWw = 2 To lr
        For RW = 1 To lr
            If B(RW) = Range("B" & RWw) Then
                Range("D" & RWw) = D(RW)
            End If
        Next RW
    Next RWw


End Sub

I really appreciate your enthusiasm. Thanks a lot!

VBA events are looked for me as a right direction.
Open_workbook event doesn't fit me because links can be updated after opening, so it will brake the integrity of data. And there is no OnLinkUpdate event.

I will try to work with on_change event combined with saving date on the hidden sheet.
 
Upvote 0

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Well, yes i would think you could just apply the code to a sheet change event, but link it to a particular range
 
Upvote 0

Forum statistics

Threads
1,215,042
Messages
6,122,810
Members
449,095
Latest member
m_smith_solihull

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