+ Reply to Thread
Results 1 to 3 of 3

Cant figure out Macro Error

Hybrid View

  1. #1
    Registered User
    Join Date
    07-13-2007
    Posts
    50

    Cant figure out Macro Error

    Hello I am using the following code but I keep getting an error message and cant figure out what is wrong:

    Sub InsertFormula5()
    With Sheets("File 1 D").Select
    LastRow = Range("A" & Rows.Count).End(xlUp).Row
    Range("P2").Formula = "=IF($H2="INTERNAL FA","Financial Advisors",IF($H2="PRIMARY CONTACT","All Sections",IF($H2="EXTERNAL FA","Allocated Sections")))"
    Range("P2").Copy
    Range("P3:P" & LastRow).Select
    Selection.PasteSpecial Paste:=xlPasteFormulas, Operation:=xlNone, _
    SkipBlanks:=False, Transpose:=False
    End With
    Range("P2").Select
    End Sub
    The Error Message that pops up says:

    Compile Error
    Expected: End of Statement

    The formula field is the one that is highlighted.

    Does anybody have any idea of what I might be doing wrong?

    Thanks

  2. #2
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Looks like you just need more quotation marks. This should work for you:
    Range("P2").Formula = _
            "=IF($H2=""INTERNAL FA"",""Financial Advisors"",IF($H2=""PRIMARY CONTACT"",""All Sections"",IF($H2=""EXTERNAL FA"",""Allocated Sections"")))"

  3. #3
    Registered User
    Join Date
    07-13-2007
    Posts
    50

    Thanks

    Hey Thanks Ikaabod. It worked.

    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