+ Reply to Thread
Results 1 to 6 of 6

VBA to recognize cell value as a number

  1. #1
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    VBA to recognize cell value as a number

    For some reason my code is not working properly. No matter what number is in the cell the Msgbox comes up. I believe that the program is not recognizing the number 1. How does vba recognize it's a number rather than just a string?

    I tried to change the cell the number, but that didn't do the trick.

    Please Login or Register  to view this content.

  2. #2
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: VBA to recognize cell value as a number

    Hi, Templemind,

    maybe you missed a dot before Cells

    Please Login or Register  to view this content.
    Ciao,
    Holger
    Use Code-Tags for showing your code: [code] Your Code here [/code]
    Please mark your question Solved if there has been offered a solution that works fine for you

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: VBA to recognize cell value as a number

    May be this...?

    Please Login or Register  to view this content.


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: VBA to recognize cell value as a number

    Thank you HaHoBe, that worked. How simple was that too.

  5. #5
    Forum Contributor
    Join Date
    08-10-2014
    Location
    Alberta
    MS-Off Ver
    2016
    Posts
    128

    Re: VBA to recognize cell value as a number

    Sixthsense, I tried his suggestion first. Yours did not seem to work for me. Thank you though

  6. #6
    Forum Guru HaHoBe's Avatar
    Join Date
    02-19-2005
    Location
    Hamburg, Germany
    MS-Off Ver
    work: 2016 on Win10 (notebook), private: 365 on Win11 (desktop), 2019 on Win11 (notebook)
    Posts
    8,199

    Re: VBA to recognize cell value as a number

    Hi, Templemind,

    for an explanation: without using the dot in front of cells this refers to the active sheet not the sheet you used Application.Match on. So an empty cell on the activesheet will always create the message while proper use of With-Statement won´t.

    Ciao,
    Holger

+ 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. Excel won't recognize cell value as a number
    By Fabienne88 in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-22-2013, 10:40 AM
  2. Recognize if the first character in a cell is a letter or a number
    By b00kjo in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 01-10-2013, 04:35 PM
  3. [SOLVED] How to recognize that a cell contains a number ??
    By rsavarain in forum Excel General
    Replies: 3
    Last Post: 09-06-2012, 06:52 PM
  4. Recognize Negative Number
    By Bob@Sun in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 01-28-2010, 06:38 PM
  5. how to recognize letters before a number in a cell
    By eithanlian in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 03-10-2007, 12:15 PM

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