How To: Create stacked labels from text in the same field
This document illustrates creating stacked labels based on a single field. For example, a field with both city name and state name, such as "Anchorage Alaska", will be labeled as follows:
City: Anchorage State: Alaska
This method does not work well for values with more than one space. For example, "Los Angeles California" will be labeled as:
City: Los State: Angeles California
For values that do not contain a space, it will not label the feature.
- Right-click the layer in the ArcMap Table of Contents and select Properties.
- Switch to the Labels tab.
- Click the Expression button.
- Check on the Advanced check box.
- Replace the existing code with the following:
Function FindLabel ( [City_State] ) Dim theString, LeftStr, RightStr, ThePos theString = [City_State] ThePos = Instr(theString, " ") - 1 LeftStr = Left (theString, ThePos) RightStr = Right (theString, Len(thestring) - ThePos) FindLabel = "City: "&LeftStr&VBNewLine&"State: "&RightStr End Function
Note: When using this code on your table, replace both occurrences of the City_State field name with the name of the field in your table.
- Click OK.
- Check the Label Features in this layer check box.
- in the Layer Properties dialog box, click Apply and click OK.
Last Published: 7/25/2019
Article ID: 000005022