+ Reply to Thread
Results 1 to 4 of 4

How to write this worksheet formula in VBA

  1. #1
    Registered User
    Join Date
    12-25-2009
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003/2007
    Posts
    43

    How to write this worksheet formula in VBA

    I want to write the following worksheet function in VBA.

    In cell B1 : =IF(OR(A1={1,2,3,4,5,6,7,8,9,0}),"Yes","No")

    Is this possible and how to do this?

    Thanks.
    Last edited by Excelfriend; 01-01-2010 at 12:05 PM.

  2. #2
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: How to write this worksheet formula in VBA

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  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: How to write this worksheet formula in VBA

    Doesn't this formula do the same without the array

    =IF((AND(A1>=0,A1<10)),"Yes","No")

    Please Login or Register  to view this content.
    Last edited by royUK; 01-01-2010 at 07:16 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
    Registered User
    Join Date
    12-25-2009
    Location
    The Netherlands
    MS-Off Ver
    Excel 2003/2007
    Posts
    43

    Re: How to write this worksheet formula in VBA

    Thank you MikeRickson for your reply!
    That's exactly what I was looking for.

    RoyUK,
    Thank you too for your reply. Indeed your formula without the array is also good and workable for me.
    But MikeRickson's is a more general one, so if I change my formula to let's say:
    =IF(OR(A1={3,7,9,14,25,66,101,270,999,1164}),"Yes","No")
    then I cannot use your solution.

    Nevertheless thanks again!

+ 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