+ Reply to Thread
Results 1 to 2 of 2

How to build a formula by using a macro

  1. #1
    Registered User
    Join Date
    02-22-2013
    Location
    Gloucestershire
    MS-Off Ver
    Excel 2010
    Posts
    14

    How to build a formula by using a macro

    I have a formula (which is an add-in from our accounts package so don't worry that it is not a normal Excel formula) which I want to 'build' either in the cell or in a macro so that the contents of two cells define the formula.

    The formula is: =EntAddNomVATLines6(AD17,AD1,AD4,AD2,AD3,AD5,"",AD16,AD6:AD15,B20:B200,H20:H200,1,E20:E200,1,S20:S200,T20:T200,U20:U200,F20:F200,"AAA","","",V20:V200,1,I20:R200)

    This basically posts a journal using data in rows 20 to 200 but I want the rows to be user definable so for instance if cells A1 and A2 contain 20 and 25 then the formula will read:
    =EntAddNomVATLines6(AD17,AD1,AD4,AD2,AD3,AD5,"",AD16,AD6:AD15,B20:B25,H20:H25,1,E20:E25,1,S20:S25,T20:T25,U20:U25,F20:F25,"AAA","","",V20:V25,1,I20:R25)

    I could probably use Indirect but I think the formula would be huge so I was wondering if I could build the formula in the cell using a macro?

    I would also like to highlight the rows currently defined by A1 and A2 so that it is clear to the user which rows will be used.

    Any thoughts?

  2. #2
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2003,2007,2010
    Posts
    31,107

    Re: How to build a formula by using a macro

    I would define that formula as a text string but with the low address/value replaced by something like |low| and the upper address/value replaced by |high|.

    Then I'd pick up the values from the cells and do a substitute. You could also use the low and high values to determine a range to highlight.


    Just my initial thoughts.

    Regards, TMS
    Trevor Shuttleworth - Excel Aid

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro to build a new sheet
    By Adam Brave in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 03-02-2012, 11:53 AM
  2. Build webqueries macro
    By aljanga in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-25-2010, 11:55 AM
  3. Need help in Macro build
    By vedamv in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 12-18-2006, 01:53 AM
  4. how do i build the macro i need?
    By Stuart in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-05-2005, 08:00 AM
  5. [SOLVED] How do I build this Macro?
    By Omakbob in forum Excel General
    Replies: 4
    Last Post: 09-28-2005, 05:05 PM

Tags for this Thread

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