anatomyst

New Member
Joined
Nov 7, 2022
Messages
3
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I have a 2D-Array and I want to look up for values in the column.
VBA Code:
arrDestination(0, i) = Name(i) (asdfg, csda, asdfg,zzz)
arrDestination(1, i) = Values(i) (100, 50, 100, 60)

My 2D Arrays contains the names and values.
If my arrDestination Array match with Column A then I want to insert the Values in B.

So for example:
  1. arrDestination(0,0) = asdfg MATCH with Column A, then insert 100.
  2. arrDestination(0,3) = zzz DOES NOT MATCH with Coulm A, insert "empty"
My attempt:

VBA Code:
For i = 0 To UBound(arrDestination, 2)
vData = Sheets("half").Range("A1:A4").value
s = arrDestination(0, i)
myVar = Application.VLookup(s, vData, 2, 1)
Next i



AB
1asdfg100
2csda50
3asdfg100
4gfsempty
 

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
VBA Code:
Dim lRow As Integer
lRow = Sheets("half").Cells(Rows.Count, 1).End(xlUp).Row

For j = 1 To lRow
  For i = 0 To UBound(arrDestination, 2)
    If arrDestination(0, i) = Sheets("half").Cells(j, 1).Value Then
      Sheets("half").Cells(j, 2).Value = arrDestination(1, i)
    End If
  Next i
Next j
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

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