Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

VBA vlookup in a named array

$
0
0

Hello,

Here's what I'm trying to do in VBA. Loop through a long list of text values in Decision Ref Column A. Check to see if each value is found within the array defined through the naming function in the formula tab, named "Treatment_Group_for_Breakdown". If the value is found in this array, I need to select (and later copy/paste) values in the row from Decision Ref.  

I'm sure there's some weird definitions or syntax in my code here. I'm told the vlookupfunction needs a variant defined ("result"), but then I get a mismatch when I ask if result matches the activecell, which I'm pretty sure is a string. 

Any light you can shed would be appreciated!

Here's the code:

    Sheets("DecisionRef").Select
    Range("A2").Select
    Do Until ActiveCell = Range("A1")
    If ActiveCell <> 0 Then
    Dim result As Variant
    result = [VLookup(ActiveCell, "Treatment_Group_for_Breakdown", 1, False)]
    On Error GoTo Down
    If ActiveCell = result Then
    ActiveCell.Range("A1:AE1").Select
Down:
    ActiveCell.Offset(1, 0).Range("A1").Select


Viewing all articles
Browse latest Browse all 11829

Trending Articles



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