HOW TO
Note: This article pertains to ArcGIS versions 8.x and 9.x. Later versions of ArcGIS may contain different functionality, as well as different names and locations for menus, commands and geoprocessing tools.
This article describes how to sort unique value symbology classes using values from a second field.When using the Layer Properties > Symbology > Categories > Match to Symbols Style method to symbolize, you can sort alphabetically on the Value Field or manually using the Up and Down arrow buttons. If you don't want alphabetic sorting, or if you have many different classes, you can sort using a second field and the following ArcObjects code.
Note: Support for Visual Basic for Applications (VBA) for ArcMap and ArcCatalog ended with the ArcGIS 10.2.2 release, and Esri has not included VBA compatibility setups since version 10.5. See: ArcGIS Desktop and VBA Moving Forward
Option Explicit Sub TrimClassLabels() Dim pMxDoc As IMxDocument Dim pGeoFeatLayer As IGeoFeatureLayer Set pMxDoc = Application.Document ' change this index to operate on another layer Set pGeoFeatLayer = pMxDoc.ActiveView.FocusMap.Layer(0) Dim pUVRend As IUniqueValueRenderer Set pUVRend = pGeoFeatLayer.Renderer Dim i As Integer Dim j As Integer Dim strLabel As String Dim strValue As String For i = 0 To pUVRend.ValueCount - 1 strValue = pUVRend.Value(i) j = InStr(strValue, ",") strLabel = Right(strValue, Len(strValue) - j) ' get rid of leading space for 2nd value strLabel = LTrim(strLabel) pUVRend.Label(strValue) = strLabel Next i pMxDoc.UpdateContents pMxDoc.ActiveView.Refresh End Sub
Article ID:000006167
Get help from ArcGIS experts
Download the Esri Support App