+ Reply to Thread
Results 1 to 3 of 3

Convert array element to a number

  1. #1
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Convert array element to a number

    I capture data in an array dimensioned as Variant and want to compare an element of the array to a number. How do I convert a single element of the array to a number? For example my array is filled like so

    "150-30041", "1", "C356"
    "150-30082", "1", "C706"

    The 2nd element of each row is a count. I want to compare this value to a number on an open worksheet. I tried a simple
    Please Login or Register  to view this content.
    where (row_n, col_n) specifies the cells to compare. However, this fails because the array element is treated as text.

    Any thoughts?

  2. #2
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,645

    Re: Convert array element to a number

    There are various converion functions you can use - Val, CLng, CInt, CSng, CDbl.

    For example.
    Please Login or Register  to view this content.
    If posting code please use code tags, see here.

  3. #3
    Registered User
    Join Date
    09-04-2013
    Location
    richardson, tx
    MS-Off Ver
    Excel 20037
    Posts
    28

    Re: Convert array element to a number

    Thanks Norie, that solved my problem.

+ 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. How to count number of occurences of each element within array
    By cgkmal in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-05-2014, 04:33 PM
  2. Replies: 12
    Last Post: 01-14-2014, 01:56 PM
  3. find the index number for an array element
    By Dick Minter in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 03-20-2006, 07:01 PM
  4. Array problem: Key words-Variant Array, single-element, type mismatch error
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 11-09-2005, 01:54 AM
  5. Array problem: Key words-Variant Array, single-element, type mismatch error
    By davidm in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-08-2005, 12:30 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