HOW TO

Selectively stack labels based on field values

Last Published: April 25, 2020

Summary

You can use VB If/Then statements to selectivley label features. For example, you want to create a stacked label from the Genus, Species, and Subspecies fields and omit empty values from the label.

Procedure



  1. Right click the layer in ArcMap's Table of Contents.
  2. Select Properties.
  3. Switch to the Labels Tab on the Layer Properties dialog box.
  4. Check the Label Features in this Layer checkbox.
  5. Click the Expressions button.
  6. Check the Advanced check box.
  7. Paste the following code into the expression box replacing the existing code.

    Code:
    Function FindLabel([GENUS],[SPECIES], [SUBSPECIES])
    Dim TheLabel
    If [GENUS] <> " " Then
    TheLabel = "Genus: " & [GENUS]
    End If
    If [SPECIES] <> " " Then
    TheLabel = TheLabel&vbnewline&"Species: " & [SPECIES]
    End If
    If [SUBSPECIES] <> " " Then
    TheLabel = TheLabel&vbnewline&"SubspeciesLabel: " & [SUBSPECIES]
    End If
    FindLabel = TheLabel
    End Function

  8. Edit the expression to reference the field names of your layer.

    Note:
    You can stack more than three labels. To do this add fields to the "Function FindLabel()" statement. Then add more IF/THEN tests for each additional field.

Article ID:000005000

Software:
  • ArcMap 8 x

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Discover more on this topic