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:
This method does not work well for values with more than one space. For example, "Los Angeles California" will be labeled as:
State: Angeles California
For values that do not contain a space, it will not label the feature.
- Right-click on 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
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 on the Label Features in this layer check box.
- On the Layer Properties dialog box, click Apply and click OK.