+ Reply to Thread
Results 1 to 2 of 2

IF formula

  1. #1
    Registered User
    Join Date
    05-28-2013
    Location
    Pembroke, Bermuda
    MS-Off Ver
    Excel 2010
    Posts
    1

    IF formula

    Hello,

    I'm fairly new to Excel programming. I'm trying to input the following formula into a designated cell:

    ActiveCell.FormulaR1C1 = "=IF(MONTH(B2)=1,"January",IF(MONTH(B2)=2,"February",IF(MONTH(B2)=3,"March",IF(MONTH(B2)=4,"April",IF(MONTH(B2)=5,"May",IF(MONTH(B2)=6,"June",IF(MONTH(B2)=7,"July",IF(MONTH(B2)=8,"August",IF(MONTH(B2)=9,"September",IF(MONTH(B2)=10,"October",IF(MONTH(B2)=11,"November",IF(MONTH(B2)=12,"December",""))))))))))))"

    Unfortunately, I get an error message saying, "Compile error: Expected: end of statement" May someone help me out with a solution please?

    Many thanks.

  2. #2
    Forum Expert dilipandey's Avatar
    Join Date
    12-05-2011
    Location
    Dubai, UAE
    MS-Off Ver
    1997 - 2016
    Posts
    8,191

    Re: IF formula

    Hi MJEB,

    welcome to the forum.
    Try below code:-
    ActiveCell.Formula = "=LOOKUP(B2,{1,2,3,4,5,6,7,8,9,10,11,12},{""january"",""february"",""march"",""april"",""may"",""june"",""july"",""august"",""september"",""October"",""november"",""december""})"


    Regards,
    DILIPandey
    <click on below * if this helps>
    DILIPandey, Excel rMVP
    +919810929744 (India), +971528225509 (Dubai), [email protected]

+ 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