+ Reply to Thread
Results 1 to 4 of 4

error handling: comparing value to "" (blank)

  1. #1
    Registered User
    Join Date
    12-12-2010
    Location
    Sydney
    MS-Off Ver
    Excel 2007
    Posts
    3

    error handling: comparing value to "" (blank)

    I am writing a function that converts a compass bearing into mathematical degrees.
    However, when applied on an empty cell, it takes the value as 0, so i'm trying to eliminate that.

    Please Login or Register  to view this content.
    The bold part is the erroneous part (the part that says
    Please Login or Register  to view this content.
    , works fine without it.
    If anyone can help out a newbie, it'd be greatly appreciated.

    Thanks in advance. =)
    Last edited by timothy.siu; 12-14-2010 at 08:47 AM.

  2. #2
    Forum Expert
    Join Date
    11-29-2010
    Location
    Ukraine
    MS-Off Ver
    Excel 2019
    Posts
    4,168

    Re: error handling: comparing value to "" (blank)

    dblBearing As Double

    Source Excel VB help:

    Double Data Type

    Double (double-precision floating-point) variables are stored as IEEE 64-bit (8-byte) floating-point numbers ranging in value from -1.79769313486231E308 to -4.94065645841247E-324 for negative values and from 4.94065645841247E-324 to 1.79769313486232E308 for positive values. The type-declaration character for Double is the number sign (#).

    So this variable does not accept value "" but takes zero.

  3. #3
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: error handling: comparing value to "" (blank)

    Something like
    Please Login or Register  to view this content.
    Last edited by royUK; 12-14-2010 at 08:52 AM.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,419

    Re: error handling: comparing value to "" (blank)

    Try this approach.

    As B2A returns a double, I've arbitrarily set the return value to -1 if it is an error.


    Please Login or Register  to view this content.

    Regards
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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