• Skip to main content
  • Skip to primary sidebar
  • Skip to footer

bVisual

  • Home
  • Services
    • How Visio smartness can help your business
    • Visio visual in Power BI
    • Visio Consulting Services
    • Visio Bureau Services
    • Visio Training and Support Services
  • Products
    • Visio Shape Report Converter
    • SS Plus
    • LayerManager
    • visViewer
    • Metro Icons
    • Rules Tools for Visio
    • The Visio 2010 Sessions App
    • Multi-Language Text for Visio
    • Document Imager for Visio
    • multiSelect for Visio
    • pdSelect for Visio
  • Case Studies
    • Case studies overview
    • Using Visio in Education for GIS
    • Visualizing Construction Project Schedules
    • Visio Online Business Process Mapping
    • Nexans Visio Template
    • CNEE Projects, WorldCom
    • Chase Manhattan Bank
  • News
    • Recent news
    • News archive
  • Resources
    • Articles➡
      • ShapeSheet Functions A-Z
      • Comparing Visio for the Web and Desktop
      • Customising Visio Shapes for the Web App
      • Key differences between the Visio desktop and web apps
      • Using the Visio Data Visualizer in Excel
      • Using Visio in Teams
      • Creating Visio Tabs and Apps for Teams with SharePoint Framework (SPFx)
      • Designing Power Automate Flows with Microsoft Visio
      • Innovative uses of Visio Lists
    • Webcasts ➡
      • Visio in Organizations
      • My session and other Visio sessions at MSIgnite 2019
      • Power up your Visio diagrams
      • Vision up your Visio diagrams
      • The Visio 2010 MVP Sessions
    • Visio Web Learning Resources
    • Books➡
      • Visualize Complex Processes with Microsoft Visio
      • Mastering Data Visualization with Microsoft Visio
      • Microsoft Visio Business Process Diagramming and Validation
      • Visualizing Information with Microsoft Visio
  • Blog
    • Browse blog articles
    • Visio Power BI articles
    • Visio for Web articles
    • A history of messaging and encryption
  • About us
    • About bVisual
    • Testimonials
    • Bio of David Parker
    • Contact Us
    • Website Privacy Policy
    • Website terms and conditions
    • Ariba Network
You are here: Home / Shape Design / ShapeSheet Formulas / Using CODE() and UNICODE() functions in Visio

Published on March 31, 2020 by David Parker

Using CODE() and UNICODE() functions in Visio

Microsoft Visio does have CHAR() and UNICHAR() ShapeSheet functions, just like Excel, but it does not have the inverse CODE() and UNICODE() functions, unlike Excel. However, there is a way to create a formula in the Visio ShapeSheet to provide these functions.

The following worksheet demonstrates how the CHAR(), CODE(), UNICHAR(), and UNICODE() functions work in Excel.

ColumnFormula
Indexn
Char=IFERROR( CHAR(INT([@Index])),””)
Code=IFERROR( CODE([@Char]),””)
Unichar=UNICHAR(INT([@Index]))
Unicode=UNICODE([@Unichar])

Notice that there are no values for either CHAR() or CODE() above 255 because they use a single bit value. However, UNICHAR() and UNICODE() use two-bit values so can work for over 65,000 values.

A similar table in Visio, constructed using a List shape, requires some formulas in the User-Defined Cells section of the ShapeSheet for the formulas in the Shape Data section to use.

The User-defined Cells formulas are:

RowFormula
User.Chars=CHAR(INT(32))&CHAR(INT(33))& … CHAR(INT(255))
User.Code=FIND(ARG(“c”),User.Chars)
User.StartAt31
User.Unichars=UNICHAR(INT(32))&UNICHAR(INT(33))& … UNICHAR(INT(402))
User.Unicode=FIND(ARG(“c”),User.Unichars)

The Shape Data section formulas are:

RowValue Formula
Prop.Index=GUARD(User.StartAt+User.ListPosition)
Prop.Char=GUARD(CHAR(Prop.Index))
Prop.Code=GUARD(EVALCELL(User.Code,”c”,Prop.Char)+User.StartAt)
Prop.Unichar=GUARD(UNICHAR(Prop.Index))
Prop.Unicode=GUARD(EVALCELL(User.Unicode,”c”,Prop.Unichar)+User.StartAt)

Now, I can use these User.Code and User.Unicode formulas in any scenario where I need to get a character from a numeric value.

The formulas for User.Chars and User.Unichars are very long, so I wrote a couple of VBA sub-routines to generate them, and ran them to print into the Immediate window.

Fortunately, the Design / Editing / Edit Formula dialog box will accept the multi-line text, and then just concatenate them into a single log string on close. I found it was necessary to explicitly convert the numbers using Int() function, otherwise the built-in Unichar() function returned just #Value.

Option Explicit

Public Sub PrintChars()
Dim i As Long
Dim s As String
Dim x As Long
Dim y As Long
    y = 52

    For x = 32 To 255 Step (y + 1)
        s = ""
        For i = x To (x + y)
            If i = 32 Then
                s = "=Char(Int(" & i & "))"
            Else
                s = s & "&Char(Int(" & i & "))"
            End If
        Next i
        Debug.Print s
    Next x
End Sub

Public Sub PrintUnichars()
Dim i As Long
Dim s As String
Dim x As Long
Dim y As Long
    y = 52
    For x = 32 To 370 Step (y + 1)
        For i = x To (x + y)
            s = ""
            If i = 32 Then
                s = "=Unichar(Int(" & i & "))"
            Else
                s = s & "&Unichar(Int(" & i & "))"
            End If
        Next i
        Debug.Print s
    Next x
End Sub

Note that I did not bother to loop through all of the 64k values for Unichars!

The Visio list shape in the Office Web Apps viewer ( or in a new tab ):

The Excel worksheet in the Office Web Apps viewer:

Further reading : The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)

Related

Filed Under: Excel, Lists, Shape Data, ShapeSheet Formulas, Visio Tagged With: Excel, ShapeSheet Functions, Visio

About David Parker

David Parker has 25 years' experience of providing data visualization solutions to companies around the globe. He is a Microsoft MVP and Visio expert.

Reader Interactions

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

  • LinkedIn
  • Twitter

Recent Posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Categories

Tags

Accessibility Add-Ins Connectors Containers Data Export Data Graphics Data Import Data Visualizer Educational Excel GraphDatabase Hyperlinks Icon Sets JavaScript LayerManager Layers Legend Link Data to Shapes Lists MSIgnite MVP Office365 Org Chart PowerApps PowerBI PowerQuery Processes Setup and Deployment Shape Data Shape Design ShapeSheet ShapeSheet Functions SharePoint 2013 SQL Teams Validation VBA Video Visio Visio 2007 Visio for the Web Visio Online Visio Services Visio Viewer Webinar

Footer

bVisual Profile

The UK-based independent Visio consultancy with a worldwide reach. We have over 25 years experience of providing data visualization solutions to companies around the globe.

Learn more about bVisual

  • Amazon
  • E-mail
  • Facebook
  • LinkedIn
  • Twitter
  • YouTube

Search this website

Recent posts

  • Fixing dimensions of 2D shapes
  • Merging Linked Data from Similar Tables
  • Smart Radio Buttons and Check Boxes in Visio
  • Using Button Face Ids in Visio
  • Grid Snapping Revisited

Copyright © 2025 · Executive Pro on Genesis Framework · WordPress · Log in