+ Reply to Thread
Results 1 to 4 of 4

Need a macro that combines LOOKUP and CONCATENATE to describe a calculation

  1. #1
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Need a macro that combines LOOKUP and CONCATENATE to describe a calculation

    I'm trying to create was it a very complicated CONCATENATE function that also uses LOOKUP, and which creates a short, simple sentence. I quickly realised that there aren't enough nested IF statements for what I want, so I tried creating Macro code to demonstrate what I want to do.

    I'm trying to create a sentence which describes how a Gross Wage figure was calculated. There are a few ways that this can be done:

    1 - a wage figure can be entered in "INC" directly. I haven't actually allowed for this yet, but in this situation, the user would have to describe themselves how they worked it out
    2 - various wage figures can be entered into "1 JOB WAGE CALC", and either the latest figure would be used (and put into "INC"), or the average would be taken (and put into "INC")
    3 - various wage figures can be entered into "2 JOB WAGE CALC" (in one of two tables), and either the latest figure would be used (and put into "INC"), or the average would be taken (and put into "INC")

    The code is then supposed to create a sentence like:
    "Gross Wage - £500/month - most recent figure used"
    "Gross Wage - £500/month - calculated as average of £400, £600, £200, £800"

    There are a few bits I'm not sure on, like how to combine LOOKUP with CONCATENATE, and the odd reference might be wrong at the moment, but for now this is what I have:

    Please Login or Register  to view this content.
    EDIT: Sorry, I thought there might be a way to preserve the formatting when I posted the code (as mine has indents). Is there a way to do that?
    Last edited by JBeaucaire; 05-18-2013 at 11:20 AM. Reason: Added CODE tags, as per Forum Rules. Take a moment to read the Forum Rules in the menu bar above. Thanks.

  2. #2
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Need a macro that combines LOOKUP and CONCATENATE to describe a calculation

    I've decided to separate the code across multiple rows in my spreadsheet, which makes things a bit easier. But I need help creating a LOOKUP function which will look through a range of cells (G8:G19), and return all figures from that range, with commas, within a concatenate statement:

    Please Login or Register  to view this content.
    Is there a LOOKUP command or similar that I can insert into this to make it work?
    Last edited by ianpwilliams; 05-19-2013 at 03:48 AM.

  3. #3
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Need a macro that combines LOOKUP and CONCATENATE to describe a calculation

    I'm thinking I would be best off using a helper cell here. So if I could concatenate any figures that were entered in cells G8 to G19 (bearing in mind many cells would usually be blank), and put commas in between them, then I could refer to the helper cell in my formula

  4. #4
    Forum Contributor
    Join Date
    12-09-2011
    Location
    UK
    MS-Off Ver
    Excel 2003
    Posts
    201

    Re: Need a macro that combines LOOKUP and CONCATENATE to describe a calculation

    I think I might be better off starting a new thread on this, just with the formula I have, as it's a lot less complicated as what I first posted here, and I'm looking at a formula instead of a macro. So please can you delete this thread?

+ 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