Combination IfNa, VLookUp and loop (For Next) in VBA

dzifna

New Member
Joined
May 24, 2022
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hi!
I try to explain my problem very quickly:
I need to use formula VLookUp in VBA, but I have two ranges (two tabels). To simplyfy my work, I use IfNA in a simple loop (For Next).

VBA Code:
Sub VBA_runda1_alter()

x = 1
For x = 3 To 12
    Cells(x, 4).Value = Application.WorksheetFunction.IfNa( _
    Application.WorksheetFunction.VLookup(Cells(x, 2).Value, [table_1], 3, 0), _
    "No decription")
Next x
End Sub

It works only for first range, after that it doesn't show any information.

Also, when i use the same method to the next loop, it doesn't show anything. I think it'a a problem with IfNA formula.

Any help, please? Thanks ;)
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Welcome to the Board!

It works only for first range, after that it doesn't show any information.
Your code only includes the first range.
If you want it to bounce to the second range, then you would need to replace the part of your code that says "No description" with another VLOOKUP formula.
 
Upvote 0

Forum statistics

Threads
1,214,875
Messages
6,122,046
Members
449,063
Latest member
ak94

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