Results 1 to 3 of 3

Thread: Need VBA Code for Excel Problem?

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2004
    Location
    Right here
    Posts
    275

    Need VBA Code for Excel Problem?

    I'm creating an Excel application and sometimes, because of the figures I put into some of the worksheets, I get the error message "#VALUE!". This isn't a problem because I know why it does it, but rather than have it say "#VALUE!" I'd rather have it say something else, in this case the text string ">50yrs".

    Do I need to use VBA code to do this? I can't find a way of doing it just using the formula bar and inputting a formula.

    Thanks
    -Rob
    Last edited by TheRobster; Mar 26th, 2005 at 05:23 PM.

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Need VBA Code for Excel Problem?

    If you want to use the formula bar then use an If statement but you will generate a circular reference. So you
    may want to use a second column for the actual numbers to display.

    VB Code:
    1. =IF(A1 > 50,">50",A1)
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3
    Fanatic Member Comintern's Avatar
    Join Date
    Nov 2004
    Location
    Lincoln, NE
    Posts
    826

    Re: Need VBA Code for Excel Problem?

    You can use ISERROR on your formula in a IF statement without creating a circular reference.

    =IF(ISERROR(A1+B1),">50yrs",A1+B1)

    Just replace A1+B1 with whatever your formula is in both places.

Posting Permissions

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



Click Here to Expand Forum to Full Width