Worksheet.XmlDataQuery (Excel)

Returns a Range object that represents the cells mapped to a particular XPath. Returns Nothing if the specified XPath has not been mapped to the worksheet, or if the mapped range is empty.

If the XPath exists within a column in an XML list, the Range object returned does not include the header row. This method returns Nothing if the XPath location path is not mapped into the grid. Thus, a return of Nothing doesn't necessarily mean that the map doesn't exist. It could mean that there is currently no data range available at the specified XPath location. You can use the XmlMapQuery method to check for the existence of a mapped XPath.

XmlDataQuery (XPath, SelectionNamespaces, Map)


Dim strXPath As String: strXPath = 
Dim rngXmlDataQuery As Range
Set rngXmlDataQuery = ActiveSheet.XmlDataQuery(XPath:=strXPath)

Arguments

The following argument is required

XPath (String) - The XPath to query for.

Optional arguments

The following arguments are optional

SelectionNamespaces (String) - A space-delimited String that contains the namespaces referenced in the XPath parameter. A run-time error is generated if one of the specified namespaces cannot be resolved.

Map (XmlMap) - Specify an XmlMap if you want to query for the XPath within a specific map.