+ Reply to Thread
Results 1 to 10 of 10

formula consisted of 2 cells only

  1. #1
    Registered User
    Join Date
    06-09-2013
    Location
    lebanon
    MS-Off Ver
    Excel 2007
    Posts
    95

    formula consisted of 2 cells only

    hello i came here cuz my problem seems somewhat complex, it may require something like a macro or VBA anyway here goes nothing lol
    and im sorry for my lack of explanation im new to excel. but ill try my best

    i want a cell to perform this following operation listed under.

    ok, = whatever number i put in the cell, it will look at the number and subtract from another cell

    another example is, whatever number i put in cell A2 lets say 3,it will subtract 3 out of whatever number is available in A1,

    also in other words, say we have 10 in cell A1, if i add 3 in cell A2, cell A1 will automatically turn to 7.
    and if theres the adding version for this it would be great!

    if anyone knows how this could be done, it will be much appreciated.

  2. #2
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: formula consisted of 2 cells only

    Hi
    Cut and paste this code behind your Worksheet (right click on the sheet tab and select View Code). Then close that view to return to Excel.

    Private Sub Worksheet_Change(ByVal Target As Range)
    'Specify the target cell whose entry shall be the sheet tab name.
    If Target.Address <> "$A$2" Then Exit Sub
    'If the target cell is empty (contents cleared) do not change the sheet name.
    If IsEmpty(Target) Then Exit Sub
    Range("A1") = Range("A1") - Range("A2")
    End Sub

    Enter a number in A1 then enter any number in A2. A1 will automatically subtract whatever is in A2 from A1 and the result will be in A1

    Hope this helps.
    Tony

  3. #3
    Registered User
    Join Date
    06-09-2013
    Location
    lebanon
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: formula consisted of 2 cells only

    it worked and im really amazed by it, thx so much friend, i really hate to be pain but i was wondering can this be done from one sheet to another and by columns ?
    i loved it but i want it on a much more bigger scale the code at work


    like this column in this worksheet will subtract itself from the other worksheets column i understood a bit how its getting written and stuff i tryed to edit it but unfortunately didn't work more then one cell, but im sure ill understand when i see how its done by columns and my goal is by the columns

    but i want to thank you for taking ur time and putting out the great code for me its really great and ill be able to put it to good once i understand how its done by columns thank you once again

  4. #4
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: formula consisted of 2 cells only

    Hi
    I am happy to help if I can but you need to provide me with the structure of your workbook, sheet names and where the values are going. Provide a sample Workbook with notes and I can then take a look.
    Tony

  5. #5
    Registered User
    Join Date
    06-09-2013
    Location
    lebanon
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: formula consisted of 2 cells only

    oh wonderful i will upload my project and i apologize for my late reply but here is my workbook and the thing that i want is

    when i add numbers in the receiving tab "stock in" column the whole column, that column automatically to calculate against the "initial QTY" column or the "current QTY" column, preferably the "current QTY" column if possible,

    ( just like the code u provided me with, it was perfect the very exact same code but on a bigger scale, like the whole column if possible cuz i can add by just simply putting the number or subtract by using the - sign like duh :P ( thats cuz i put + instead of the - in the code range area ) but yeh still cool it had the minus feature just in case something went wrong )

    and in the "sold stock" tab , "sold QTY" column whatever number i add inside, it will calculate against the "QTY out" column inside the "Stock out" tab lol... i know im asking too much i hope im not being anoying or a pain hah but thanks a lot man ur talented.

    what im aiming for is a simple way to manage stock but those are the formula's which are missing. hopefully hope it works out !
    Attached Files Attached Files

  6. #6
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: formula consisted of 2 cells only

    Hi
    Please find attached solution.
    Hope this is what you needed.
    Tony
    Attached Files Attached Files

  7. #7
    Registered User
    Join Date
    06-09-2013
    Location
    lebanon
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: formula consisted of 2 cells only

    well mate it seems to be working but i forgot to mention i had a formula in "current QTY" in the receive tab, the macro is removing the formula as soon as its operational, is it possible to add the macro over a cell which has formula in it ? , if not i will just replace the macro in the initial QTY. and it will work fine

    and im so sorry i know u did more then enough and ur work is amazing but just one thing left i wanted the same macro which u build in receive tab but from " sold stock sheet sold QTY column" to "stock out sheet QTY out column" i would have edited it myself, but i dont know how to jump from one sheet to another

    btw cant thank you enough even if the if the macro cant be added on the "current QTY column" since it has formula in it, i can still add it on initial balance area ! thanks man tony its very generous of u to help me
    Last edited by raffi123; 06-18-2013 at 05:19 AM.

  8. #8
    Valued Forum Contributor
    Join Date
    10-26-2008
    Location
    Birmingham, UK
    MS-Off Ver
    All versions up to 2010
    Posts
    1,025

    Re: formula consisted of 2 cells only

    Hi
    You don't need a second macro on the Sold Stock Sheet. I have linked the cells on the two sheets so that as soon as you enter figures in the Sold Stock sheet those figures are automatically updated to the Stock Out sheet via cell links. This is why I advised that both sheets need to have exactly the same products in the same order.
    Hope this helps.
    Good luck.
    Tony

  9. #9
    Registered User
    Join Date
    06-09-2013
    Location
    lebanon
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: formula consisted of 2 cells only

    its just pasting the same number, its not subtracting or adding like the one which is found in receive tab oh well i think u'v helped me enough =l well thx anyway and thanks for baring with me till now and providing me with the macro's

  10. #10
    Registered User
    Join Date
    06-09-2013
    Location
    lebanon
    MS-Off Ver
    Excel 2007
    Posts
    95

    Re: formula consisted of 2 cells only

    ok bro i solved the problem i took another approach hard to get into the details but to make a long story short i used ur macro on 3 pages and its working very nicely all thanks to u and that beautiful wonderful macro thx dude ur the man !!!!

+ 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