Consulting

Results 1 to 3 of 3

Thread: unable to set the formulaarray property of the range class - IF AND

  1. #1
    VBAX Regular
    Joined
    Nov 2016
    Posts
    20
    Location

    unable to set the formulaarray property of the range class - IF AND

    Hello


    I got an error message (... error 1004 - unable to set the formulaarray property of the range class) when I try to use the following VBA code.


    I defined three constants:


    Const Formula1_Valid = "=IF(AND(D38<E38; D39<E39; D40<E40); ""VALID""; ""NOTVALID"")"
    Const Formula2_Valid = "=IF(AND(D38<E38; D39<E39; D40<E40; F38<G38; F39<G39; F40<G40); ""VALID""; ""NOTVALID"")"
    Const Formula3_Valid = "=IF(AND(D38<E38; D39<E39; D40<E40; F38<G38; F39<G39; F40<G40; H38<I38; H39<I39; H40<I40); ""VALID""; ""NOTVALID"")"


    When a certain event occurs (If Target.Address = "$G$5" Then...) I would like to put a formula into a cell E45.


    I try to use the following instruction: Sheet1.Range("E45").FormulaArray= Formula1_Valid


    What is the problem with this code?
    It works if I use the following constant: =SUM(F38:G38)
    The cell E45 hasn"t been merged. The formula doesn't exceed 255 Characters.

  2. #2
    VBAX Guru mancubus's Avatar
    Joined
    Dec 2010
    Location
    "Where I lay my head is home" :D
    Posts
    2,644
    i dont think you need an array formula.
    instead try FormulaLocal property (since argument separator is ";") or Formula property by replacing semicolons with commas.
    PLS DO NOT PM; OPEN A THREAD INSTEAD!!!

    1) Posting Code
    [CODE]PasteYourCodeHere[/CODE]
    (or paste your code, select it, click # button)

    2) Uploading File(s)
    Go Advanced / Attachments - Manage Attachments / Add Files / Select Files / Select the file(s) (multiple files can be selected while holding Ctrl key) / Upload Files / Done
    Replace company specific / sensitive / confidential data. Include so many rows and sheets etc in the uploaded workbook to enable the helpers visualize the data and table structure. Helpers do not need the entire workbook.

    3) Testing the Codes
    always back up your files before testing the codes.

    4) Marking the Thread as Solved
    from Thread Tools (on the top right corner, above the first message)

  3. #3
    VBAX Regular
    Joined
    Nov 2016
    Posts
    20
    Location
    Thank you so much for your help. I really appreciate it.
    FormulaLocal is perfect.

Tags for this Thread

Posting Permissions

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