converting isnumber(match) and vlookup to vba

Phitur

New Member
Joined
Jul 23, 2010
Messages
21
I currently have my macro populating cells on my spreadsheet and letting the spreadsheet perform the calculations. The sheets are getting very large and the calcs are slowing it down. So instead, I'd like to have the code perform the calcs and put the values in the cells.

The current equation:

=IF(ISNUMBER(MATCH(B2,'EMP List'!A:A,0)),IF(VLOOKUP(B2,'EMP List'!A:G,7,0)="","n/a",VLOOKUP(B2,'EMP List'!A:K,11,0)),"")

With code:

Range("H2").Value = "=IF(ISNUMBER(MATCH(B2,'EMP List'!A:A,0)),IF(VLOOKUP(B2,'EMP List'!A:G,7,0)=" & Chr(34) & _
Chr(34) & "," & Chr(34) & "n/a" & Chr(34) & ",VLOOKUP(B2,'EMP List'!A:K,11,0))," & Chr(34) & Chr(34) & ")"

How do I translate this into a VBA only claculation and input the value in cell H2?

Thanks!
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
I figured out my problem. I had the i and "B" backwords in Cells(i, "B"). It was giving me a type mismatch error. This is what I came up with.

If IsNumeric(Application.Match(Cells(i, "B"), Worksheets("EMP List").Range("A:A"), 0)) = True Then
If Application.VLookup(Cells(i, "B"), Worksheets("EMP List").Range("A:G"), 7, 0) = "" Then
Cells(i, "H").Value = "n/a"
Else: Cells(i, "H").Value = Application.VLookup(Cells(i, "B"), Worksheets("EMP List").Range("A:K"), 11, 0)
End If
End If
 
Upvote 0

Forum statistics

Threads
1,215,463
Messages
6,124,965
Members
449,201
Latest member
Jamil ahmed

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