VLookup

rollingzep

Board Regular
Joined
Nov 18, 2013
Messages
214
Office Version
  1. 365
Platform
  1. Windows
Hi,

<p>
I have a vlookup between two worksheets.

It is as follows

ws.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=VLOOKUP(""*""&RC[-22]&""*"",HQLA!C1:C35,35,0)"

How do I modify the above, so that if the length of col, Y is 9, then it will be the above formula or
if the length is 12, then it should be

ws.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=IFERROR(VLOOKUP(""*""&RC[-22]&""*"",HQLA!C3:C33,33,0)

</p>
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
Hi,

<p>
I have a vlookup between two worksheets.

It is as follows

ws.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=VLOOKUP(""*""&RC[-22]&""*"",HQLA!C1:C35,35,0)"

How do I modify the above, so that if the length of col, Y is 9, then it will be the above formula or
if the length is 12, then it should be

ws.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=IFERROR(VLOOKUP(""*""&RC[-22]&""*"",HQLA!C3:C33,33,0)

</p>
Actually the second formula should be

ws.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=VLOOKUP(""*""&RC[-22]&""*"",HQLA!C3:C33,33,0)
 
Upvote 0
Can I do this way? I am not sure how to construct this code and I need help

<code>
arr = ws.Range("Y2:Y" & Cells(Rows.Count, 1).End(xlUp).Row)
Set rng = wsA.Range("AU2:AU" & Cells(Rows.Count, 1).End(xlUp).Row)
For i = 1 To UBound(arr)
For c = 1 To rng.Rows.Count
If Len(arr(i, 1)) > 9 Then
wsA.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=VLOOKUP(""*""&RC[-22]&""*"",HQLA!C1:C35,35,0)"
Else
wsA.Range("AU2:AU" & ws.Cells(Rows.Count, "Y").End(xlUp).Row).FormulaR1C1 = "=VLOOKUP(""*""&RC[-22]&""*"",HQLA!C3:C33,33,0)"
..................................
......................................................
</code>
Thanks,
 
Upvote 0

Forum statistics

Threads
1,215,408
Messages
6,124,727
Members
449,185
Latest member
ekrause77

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