Evaluating a Formula via VBA

reberryjr

Well-known Member
Joined
Mar 16, 2017
Messages
714
Office Version
  1. 365
Platform
  1. Windows
I have a record set with ~17K records, but I only need to see ~500 of them. I'm unable to alter the source of the data that I receive, so I'm trying to delete the rows I don't need, via VBA. I haven't tried using the Evaluate function before, and for some reason, I'm not able to get this to work. I've googled quite a bit, and the code below seems to match what others have used, but it's returning a #VALUE error.

Thoughts?

Code:
With dI.Range("T2", dI.Range("B" & Rows.Count).End(xlUp).Offset(, 18))
    '.Value = Evaluate("IF(ISNA(VLOOKUP(RC[,-10],BK_Issues,1,FALSE)),""N"",""Y"")")
    .Value = [IF(ISNA(VLOOKUP(RC[,-10],"BK_Issues",1,FALSE)),""N"",""Y"")")]
End With
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Try...

Code:
With dI
    With .Range("T2:T" & .Cells(.Rows.Count, "B").End(xlUp).Row)
        .FormulaR1C1 = "=IF(ISNA(VLOOKUP(RC[-10],BK_Issues,1,FALSE)),""N"",""Y"")"
        .Value = .Value
    End With
End With

Hope this helps!
 
Upvote 0
I have a record set with ~17K records, but I only need to see ~500 of them. I'm unable to alter the source of the data that I receive, so I'm trying to delete the rows I don't need, via VBA. I haven't tried using the Evaluate function before, and for some reason, I'm not able to get this to work. I've googled quite a bit, and the code below seems to match what others have used, but it's returning a #VALUE error.

Thoughts?

Code:
With dI.Range("T2", dI.Range("B" & Rows.Count).End(xlUp).Offset(, 18))
    '.Value = Evaluate("IF(ISNA(VLOOKUP(RC[,-10],BK_Issues,1,FALSE)),""N"",""Y"")")
    .Value = [IF(ISNA(VLOOKUP(RC[,-10],[B][COLOR="#FF0000"]"BK_Issues"[/COLOR][/B],1,FALSE)),""N"",""Y"")")]
End With
Assuming "BK_Issues" is a text string, you need to double up the quote marks surrounding it just the way you did for the "N" and "Y" text strings.
 
Upvote 0
@Rick Rothstein Thank you for the response. The "BK_Issues" is a named range, not a string. I see that I failed to include that in my problem statement...my apologies.
 
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,259
Members
452,626
Latest member
huntinghunter

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