I'm trying to use the worksheetfunction MATCH() in vba. I'm referencing a listobject:
debug.print Application.Match("Austria", qryGeoSubRegions[SubRegionname])
but it just returns an error Expected: List Separator or ')'
, it doesn't seem to like the table column reference. Any ideas why?
There might be a problem with your column reference. Can you confirm that
qryGeoSubRegions[SubRegionname]
refers to aa contiguous range of cells containing possible lookup values?
You could test this idea with a simpler definition of the range, like
debug.print Application.Match("Austria", Worksheets(1).Columns(1), 0)
The problem is that you are using a worksheet reference in vba. Either change the reference to vba or use Evaluate:
debug.print Application.Match("Austria", Range("qryGeoSubRegions[SubRegionname]"))
OR
debug.print Activesheet.Evaluate("MATCH(""Austria"", qryGeoSubRegions[SubRegionname])")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.