+ Reply to Thread
Results 1 to 10 of 10

Inserting ">","<" etc. in a formula

  1. #1
    Registered User
    Join Date
    10-25-2007
    Posts
    35

    Inserting ">","<" etc. in a formula

    Hi, I'm trying to write some code that inserts a SUMIF function to a given range of cells:

    In simplified form, the code runs as follows:

    Please Login or Register  to view this content.
    The problem is with the ""<"" bit as VBA keeps interpreting it as "" is less than "", thus returning FALSE in cell A1 instead of the function. How do I sort this out?
    Last edited by owainl; 12-10-2008 at 10:39 AM.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    What is the actual formula?

    If you are using VBA, do you need the formula or just the result?
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    10-25-2007
    Posts
    35
    The actual formula is:

    Please Login or Register  to view this content.
    I don't mind just having the result but I can't really be bothered to write the code. I'd quite like to know - for future reference - how to insert symbols such as '<', '>', '<>', '<=', '>=' into formula without VBA getting confused...

  4. #4
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    That's not the formula as it appears in the cell which is what I asked for.

    You can't enter a formula with VBA references in it

  5. #5
    Registered User
    Join Date
    10-25-2007
    Posts
    35
    Oh, ok. Sorry - my mistake. The formula is to be inserted in a number of cells and is dynamic but the formula in the first cell ought to be:

    =SUMIF(G3:G65,"<" &J69,K3:K65)

  6. #6
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Why not use dynamic named ranges for ranges? If you use that formula in VBA then the ranges will change according to where you place the formula unless you have absolute references.

  7. #7
    Registered User
    Join Date
    10-25-2007
    Posts
    35
    I want the ranges to change for each cell (except for the sumif range which will always be the G column - see the VBA code above). The formula works fine except that I can't get VBA to recognise the "is less than" (<) sign as being part of the formula.

  8. #8
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    See if this helps
    Please Login or Register  to view this content.

  9. #9
    Registered User
    Join Date
    10-25-2007
    Posts
    35
    Thanks - although I haven't used your answer, the ",""<""" part now works in my formula.

  10. #10
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    At least you saw how to use the <. Please mark the thread solved.

+ 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