Filtering a column in a query where I used a custom VBA function

BnYmN

New Member
Joined
Oct 7, 2015
Messages
1
When I want to filter a column where I used a self-written VBA function it gives me a type mismatch error. Is there no way to set a filter to that column?

vbatut04l.gif


This is an example I found at Google. That's how I use the function but you can't have filter criteria. It gives you an error when you execute the query.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Welcome to the Board!

Firstly, don't name your field the same as your function, that can really cause confusion and unexpected results.

Can you post the VBA code behind your Age function?

How exactly are you trying to Filter it?
Are you placing something on the Criteria row under the "Age" field?
If so, tell us exactly what you are trying.
 
Upvote 0
Agree with the name as posted by Joe4. I'll bet [Dob] is a form field reference. You cannot use that syntax - you need the complete forms reference. Assuming you'd rather rename the function as opposed to the field name:

Age:getAge(Forms!frmNameOfYourForm![Dob]) Sometimes the second ! is required, though I'm in the habit of just using a period, but not for the first !.

You can also try a hard coded value that you expect to be passed to the function but I can't tell what's in Dob to make any suggestions.
If you try these with no luck, do post your function as requested.
 
Upvote 0

Forum statistics

Threads
1,221,841
Messages
6,162,314
Members
451,759
Latest member
damav78

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