Subtract using vba minus0

  • MODERATOR NOTICE: This topic has also been posted on other sites and may already have an answer elsewhere. Please take this into consideration when answering this question

    Hi to all experts,



    i have a file with multiple sheets with same format and it subtracts automatically C-D using vba and puts the answer E when i paste new data on it

    What i want to do is apply this vba code to F-G=H and I-J=K and P-Q=R on each sheet but couldn't



    I use this for consolidating datas which i get every month from branches and i just want to copy and paste whole sheet at once (not column by column) whitout controlling if there are any wrong formulas on it..

    I couldnt attach my exact file but have a wetransfer link for it.



    and


    There is two code on each sheet, one is,

    Code
    1. Private Sub Worksheet_Change(ByVal Target As Range)
    2. Dim LastRw As Long
    3. LastRw = ListObjects(1).DataBodyRange.Rows.Count + 10 'Last table row + 10
    4. If Not Intersect(Target, Range("C11:d" & LastRw)) Is Nothing Then
    5. Call CminusO(LastRw)
    6. End If
    7. End Sub

    second code is like that,

    Sample minus0.xlsm




    Thanks a looottt in advance.

    Best regards..

  • Welcome to the Forum. Please read the Forum Rules to understand how the Forum works and why I have added Code Tags to your post


    All VBA code posted in the forum must be wrapped in code tags, which you omitted, including single-line code snippets.Be sure to use them in future posts.


    How to use code tags


    Just highlight all of the code and press the <> in the post menu above button to add the code tags.


    Also, we do not accept external links to files. READ THE FORUM RULES.


    Thanks.

  • Cross-posting is when you post the same question in other forums on the web. You'll find people are disinclined to respond to cross-posts because they may be wasting their time solving a problem that has been solved elsewhere. We prefer that you not cross-post at all, but if you do (and it's unlikely to go unnoticed), you MUST provide a link (copy the URL from the address bar in your browser) to the cross-post. We are here to help so help us help you!




    Read this to understand why we ask you to do this



    https://www.excelguru.ca/content.php?184