Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

How to update a field in a text file referencing an Index & Match?

$
0
0

I'm trying to get a field in a text file output to update referencing an Index match inside an Array (temp table), but the output is mixed up .

STEPS:

Created the Array Use Index Match to set column B to column D to populate column H

Range("H2:H17") = "=INDEX(D2:D17,MATCH(B2:B17,B2:B17,0))"

ARRAY enter image description here

CODE TO PULL COLUMN B BASED ON COLUMN D in Array:

Sheets("Array").Select

EditLine = Line

DoEdit = Range("B"& CustRow - 1).Value
If DoEdit <> "" Then
    If Target <> "" Then
       Target = DoEdit
    End If
    EditLine = Line
End If

ISSUE:

The issue is using existing/modified code I am getting what seems like random output.

The correct output should follow the array above
96NW2702 =  test1 
0039430695 = test3 
23832026 =  test11

actual output (this is what's updating in the text file) that is out of order/mixed Array3

QUESTION:

How do I modify existing code that creates text file output to call on DoEdit to check column B versus column D ..basically do what the index & match is doing above? I tried the following:

Sheets("Array").Select

EditLine = Line

DoEdit = Range("B"& CustRow).Value
If DoEdit <> "" Then
    If Target <> "" Then
       Target = DoEdit
    End If
    EditLine = Line
End If

I also tried setting Target = "=INDEX(D2:D17,MATCH(B2:B17,B2:B17,0))" but no luck either.

Thanks in advance for any help!


Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>