+ Reply to Thread
Results 1 to 11 of 11

vba to subtract two column values and add new too if added in second sheet

  1. #1
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    vba to subtract two column values and add new too if added in second sheet

    sameple workbook with sheets of sample data and result is attached ,kindly assist


    Subtract sheet 2 values from sheet 1 and give them in result
    Attached Files Attached Files
    Last edited by ROHAN999; 09-11-2018 at 01:33 PM.

  2. #2
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    Re: vba to subtract two column values and add new too if added in second sheet

    Plz somebody assist

  3. #3
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    Re: vba to subtract two column values and add new too if added in second sheet

    Shall i modify or upload other sample

  4. #4
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    Re: vba to subtract two column values and add new too if added in second sheet

    Plz somebody take it up

  5. #5
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: vba to subtract two column values and add new too if added in second sheet

    Hi Rohan,

    Looking at your problem, it doesn't make sense to me. You have two sheets with Employee numbers and Pay on each sheet. Are these sheets different days of work? The Emp No on each sheet may not be the same. If you subtract the values of sheet 2 from sheet 1 the result for employee 9 should be negative 2 and not positive 2.


    So - if your result sheet is correct, you want to add the values from both sheets but that is not what you suggest in your question.


    This may be why you aren't getting much help with this.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  6. #6
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: vba to subtract two column values and add new too if added in second sheet

    There is no structure in your example file. A possible solution in the appendix.

    Please Login or Register  to view this content.
    Sample data.xls

  7. #7
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    Re: vba to subtract two column values and add new too if added in second sheet

    thanx vraag

    your code works fine as the result given

    but by my mistake i left (-) minus sign in one


    actually the result would be :

    emp no ... pay
    2 ... -9
    9 ... 2
    13 ... 3
    124 ... 4


    As employee 2 is not there in sheet 2 so it will be subtracted from zero so negative

    rest everything is fine.

    Kindly modify the code a bit. i apologize for my mistake in showing result.
    Last edited by ROHAN999; 09-15-2018 at 02:59 PM.

  8. #8
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: vba to subtract two column values and add new too if added in second sheet

    with a small change

    Please Login or Register  to view this content.

  9. #9
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    Re: vba to subtract two column values and add new too if added in second sheet

    .Cells(1).CurrentRegion.Sort .Cells(1), , , , , , , 1

    Error msg coming here sir
    Unable to get the sort property of range claśs

    Except this code is working fine

  10. #10
    Valued Forum Contributor
    Join Date
    04-01-2015
    Location
    The Netherlands
    MS-Off Ver
    2003/2007/2010/2016/office 365
    Posts
    880

    Re: vba to subtract two column values and add new too if added in second sheet

    If your data does not start in A1 then you will have to adjust the range. Cells(1) is Range("A1")

    https://www.excel-easy.com/vba/examp...entregion.html

  11. #11
    Forum Contributor
    Join Date
    03-11-2013
    Location
    india
    MS-Off Ver
    Excel 2007
    Posts
    726

    Re: vba to subtract two column values and add new too if added in second sheet

    Thank you sir

+ 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. Replies: 1
    Last Post: 12-28-2015, 08:43 AM
  2. [SOLVED] Count most recent 12 values in a column that are >0 when values are added monthly
    By Phillycheese5 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 09-03-2014, 04:31 PM
  3. Formula to subtract 7th column values from the column before the 1st (loop)
    By saya_26 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-22-2014, 09:13 AM
  4. VBA code to Subtract values in Column F with Column E if found non-blank
    By hydz1213 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-05-2013, 04:34 AM
  5. Subtract Values in the same column help
    By GE2014 in forum Excel General
    Replies: 7
    Last Post: 05-31-2012, 01:01 PM
  6. subtract values in a column
    By mdshotgun in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-24-2011, 11:28 AM
  7. Subtract time with text added
    By Wskip49 in forum Excel General
    Replies: 7
    Last Post: 11-18-2009, 11:09 AM

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