+ Reply to Thread
Results 1 to 13 of 13

Thread: VB doesn't like this Formula?

  1. #1
    DISMfish
    Guest

    VB doesn't like this Formula?

    I don't understand why vb doesn't like this formula. Please help me
    see what I am overlooking...

    Dim Last_Column As Range
    Set Last_Column = Worksheets(sName).Range("T2:T10")

    Last_Column.Formula = "=IF(OR(" _
    AND(" & Min_Limit & "<=Q2," & Max_Limit & ">=Q2), _
    AND(" & Min_Limit & "<=R2," & Max_Limit & ">=R2), _
    AND(" & Min_Limit & ">=Q2," & Max_Limit & "<=R2)),1,0)"


  2. #2
    Duncan
    Guest

    Re: VB doesn't like this Formula?

    double quotations needed? ("""")


  3. #3
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    Where?


  4. #4
    Registered User
    Join Date
    02-15-2006
    Posts
    18
    When trying to write a formula to a cell you need to double up on your quotations

    Last_Column.Formula = "=IF(OR("" _
    AND("" & Min_Limit & ""<=Q2,"" & Max_Limit & "">=Q2), _
    AND("" & Min_Limit & ""<=R2,"" & Max_Limit & "">=R2), _
    AND("" & Min_Limit & "">=Q2,"" & Max_Limit & ""<=R2)),1,0)"
    When it puts the Formula in the cell it will remove the additional quotes. remember only double quotes for the formula that will be in the cell not around the formula. Hope THis Helps

  5. #5
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    Ok, I changed to the following, but I'm still getting an error...?

    Last_Column.Formula = "=IF(OR( _
    AND("" & RF_Min_Limit & ""<=Q2,"" & RF_Max_Limit & "">=Q2), _
    AND("" & RF_Min_Limit & ""<=R2,"" & RF_Max_Limit & "">=R2), _
    AND("" & RF_Min_Limit & "">=Q2,"" & RF_Max_Limit & ""<=R2)),1,0)"


  6. #6
    Bob Phillips
    Guest

    Re: VB doesn't like this Formula?

    I don't think it is double quotes that you need as I think Min_Limit and
    Max_Limit are numbers.

    Try

    Dim Last_Column As Range
    Set Last_Column = Worksheets(sname).Range("T2:T10")

    Last_Column.Formula = "=IF(OR(" & _
    "AND(" & Min_Limit & "<=Q2," & Max_Limit & ">=Q2)," & _
    "AND(" & Min_Limit & "<=R2," & Max_Limit & ">=R2)," & _
    "AND(" & Min_Limit & ">=Q2," & Max_Limit & "<=R2)),1,0)"

    --
    HTH

    Bob Phillips

    (remove xxx from email address if mailing direct)

    "DISMfish" <DISMfish@gmail.com> wrote in message
    news:1147787799.682216.206080@i39g2000cwa.googlegroups.com...
    > Ok, I changed to the following, but I'm still getting an error...?
    >
    > Last_Column.Formula = "=IF(OR( _
    > AND("" & RF_Min_Limit & ""<=Q2,"" & RF_Max_Limit & "">=Q2), _
    > AND("" & RF_Min_Limit & ""<=R2,"" & RF_Max_Limit & "">=R2), _
    > AND("" & RF_Min_Limit & "">=Q2,"" & RF_Max_Limit & ""<=R2)),1,0)"
    >




  7. #7
    Tom Ogilvy
    Guest

    Re: VB doesn't like this Formula?

    You can't put a continuation character inside a string

    s = "ABC _
    EFG"

    doesn't work.

    s = "ABC" & _
    "EFG"

    --
    Regards,
    Tom Ogilvy


    "DISMfish" wrote:

    > Ok, I changed to the following, but I'm still getting an error...?
    >
    > Last_Column.Formula = "=IF(OR( _
    > AND("" & RF_Min_Limit & ""<=Q2,"" & RF_Max_Limit & "">=Q2), _
    > AND("" & RF_Min_Limit & ""<=R2,"" & RF_Max_Limit & "">=R2), _
    > AND("" & RF_Min_Limit & "">=Q2,"" & RF_Max_Limit & ""<=R2)),1,0)"
    >
    >


  8. #8
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    Thanks, that did it!


  9. #9
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    Thanks, that did it!


  10. #10
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    Where? What's the difference between single and double?

    Thanks


  11. #11
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    ^ Please disregard the previous comment. It looks like there was a lag
    in posting that comment.

    Thanks Tom and Bob!


  12. #12
    Ardus Petus
    Guest

    Re: VB doesn't like this Formula?

    Last_Column.Formula = "=IF(OR(" & _
    "AND(" & Min_Limit & "<=Q2," & Max_limit & ">=Q2)," & _
    "AND(" & Min_Limit & "<=R2," & Max_limit & ">=R2)," & _
    "AND(" & Min_Limit & ">=Q2," & Max_limit & "<=R2)),1,0)"

    HTH
    --
    AP

    "DISMfish" <DISMfish@gmail.com> a écrit dans le message de news:
    1147786202.388381.111010@j33g2000cwa.googlegroups.com...
    >I don't understand why vb doesn't like this formula. Please help me
    > see what I am overlooking...
    >
    > Dim Last_Column As Range
    > Set Last_Column = Worksheets(sName).Range("T2:T10")
    >
    > Last_Column.Formula = "=IF(OR(" _
    > AND(" & Min_Limit & "<=Q2," & Max_Limit & ">=Q2), _
    > AND(" & Min_Limit & "<=R2," & Max_Limit & ">=R2), _
    > AND(" & Min_Limit & ">=Q2," & Max_Limit & "<=R2)),1,0)"
    >




  13. #13
    DISMfish
    Guest

    Re: VB doesn't like this Formula?

    Thanks, that did it!


+ 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.2.0