+ Reply to Thread
Results 1 to 5 of 5

Get the number associated tith a character using VBA? (need VBA alternative to "code($)"

  1. #1
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Get the number associated tith a character using VBA? (need VBA alternative to "code($)"

    How can I look up the number for a specified character using VBA? On a worksheet, if I have the less than symbol (<) in Cell A1, and put the formula =CODE(""&A1&"") in B1 and it gives me the result 60. With VBA I've tried using application.worksheetfunction but ".code" isn't a choice and I cannot find an alternative way to do it using VBA? Anyone have any suggestions? Thanks for reading!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    25,416

    Re: Get the number associated tith a character using VBA? (need VBA alternative to "code($

    Why are you wrapping quotes around A1? You could just do:

    =CODE(A1)

    Hope this helps.

    Pete

  3. #3
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Get the number associated tith a character using VBA? (need VBA alternative to "code($

    sorry, I was trying to illustrate what I was trying do do with VBA and using using the worksheet function as an example with a variable. What I need is code for x = application.worksheetfunction.code(character) But ".code" is not a choice. Hope this clarifies my question. Sorry for the confusion. Let me know if you have other questions. Thanks.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,393

    Re: Get the number associated tith a character using VBA? (need VBA alternative to "code($

    If I understand, what you are looking for is the VBA Asc() function.

    Asc() function information: https://www.excelfunctions.net/vba-asc-function.html
    VBA function list: https://www.excelfunctions.net/vba-functions.html
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    09-21-2014
    Location
    Midwest USA
    MS-Off Ver
    2010
    Posts
    349

    Re: Get the number associated tith a character using VBA? (need VBA alternative to "code($

    Yes, ASC is exactly what I was searching for - Thanks MrShorty!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Replacing Code(63)"?" - ASCII Character
    By mubashir aziz in forum Excel General
    Replies: 4
    Last Post: 12-22-2024, 02:33 PM
  2. Replies: 14
    Last Post: 05-11-2020, 07:47 AM
  3. Replies: 6
    Last Post: 06-25-2019, 12:19 PM
  4. [SOLVED] Faster code to delete character "#"
    By Villalobos in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-01-2015, 04:26 AM
  5. Replies: 1
    Last Post: 08-10-2014, 01:22 PM
  6. [SOLVED] How to Count number of "Error" and "OK" after the word "Instrument" found in table row
    By eltonlaw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-17-2012, 06:26 AM
  7. Macro to insert "+" character before a number
    By schtumpster in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 08-26-2009, 07:44 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1