+ Reply to Thread
Results 1 to 4 of 4

how define variables in number format and then sum those values

  1. #1
    Registered User
    Join Date
    03-24-2024
    Location
    Czech Republic
    MS-Off Ver
    365
    Posts
    1

    how define variables in number format and then sum those values

    Hi guys, I need make this:

    I have those values: 298, 345, 675, 236. Now I need define to this another number, like this:
    1 = 298
    2 = 345
    3 = 675
    4 = 236

    So, when I type in cell "1", in reality this is 298, but in cell it should be not visible like 298, just 1. And then maybe under that cell in new cell if I write 3 and this cell would be display 3 but in background it would mean 675. And then I want make SUM, so in our example SUM of those two cells with 1 and 3 displayed, but I want in this SUM cell to be displayed not 4, but 973, so it should sums value of 1 and 3, so 298+675.

    I really can not understant how I can make this and I thank you in advance for helping me! Appreciate it!

  2. #2
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,728

    Re: how define variables in number format and then sum those values

    You could do it using defined named ranges, but in Excel the name cannot be a number, so set those values on the left to _1, _2, _3, _4. You can then use Name manager to allocate those names to the cells next to them.

    Suppose you then put _2 in A7 and _4 in A8, then you could use this formula to add the underlying values together:

    =SUM(INDIRECT(A7),INDIRECT(A8))

    I'm not sure why you would want to go to all that trouble, but hope this helps.

    Pete

    EDIT: By the way, you may need to use semicolons ( ; ) instead of commas ( , ) in the formula, depending on your regional settings.

    Pete

  3. #3
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,447

    Re: how define variables in number format and then sum those values

    In principle, you could do it like this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    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


  4. #4
    Forum Expert rorya's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365 Ent Monthly Channel / Insiders Beta
    Posts
    8,913

    Re: how define variables in number format and then sum those values

    You could also put those values in a two column range (or use defined names) somewhere, then use XLOOKUP to return the relevant values to sum. Eg you put the lookup table in J1:K4, then with your 1 and 3 in A1:A2, you'd use:

    =SUM(XLOOKUP(A1:A2,J1:J4,K1:K4,0))
    Rory

+ 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. USing a variable to define the number of decimals in a certain format
    By Michael_BU in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-08-2020, 07:15 AM
  2. Using variables to define a range
    By Aelyn in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 08-27-2011, 04:27 AM
  3. Can't find a way to define variables
    By Mole in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-18-2011, 02:42 PM
  4. need help to define a range using two variables
    By dschmitt in forum Excel General
    Replies: 1
    Last Post: 03-15-2010, 08:31 PM
  5. need help to define a range using two variables
    By dschmitt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2010, 08:14 AM
  6. [SOLVED] How do you define variables in excel?
    By BigRon in forum Excel General
    Replies: 6
    Last Post: 04-16-2005, 04:06 PM
  7. How do I define a Format Cell Number Category
    By JimM in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-11-2005, 12:06 PM

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