Copy and paste of the data between sheets with add/subtract

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Copy and paste of the data between sheets with add/subtract

Post by leonardo1234 »

Copy and paste of the data between sheets with add/subtract
Plz see the sample file
Everything is mentioned and shown
if any doubts plz let me know
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78535
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Copy and paste of the data between sheets with add/subtr

Post by HansV »

Please explain clearly and explicitly what we should add or subtract.
Best wishes,
Hans

User avatar
Oliver
2StarLounger
Posts: 128
Joined: 08 Mar 2010, 13:53
Location: Missouri

Re: Copy and paste of the data between sheets with add/subtr

Post by Oliver »

Your comments in the sheets did not help, explain better por favor.
Regards,
Oliver
“Just because something doesn't do what you planned it to do doesn't mean it's useless.” -Thomas Edison

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

Now plz look into it
Plz see all sheets
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78535
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Copy and paste of the data between sheets with add/subtr

Post by HansV »

This is basically just a variation of the questions you've been asking before. You should be able to modify the macros that we have already given you to add/subtract the numbers.
Best wishes,
Hans

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

Sir can u share the link bcoz as i remember This is my first question

User avatar
HansV
Administrator
Posts: 78535
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Copy and paste of the data between sheets with add/subtr

Post by HansV »

See for example:
http://www.eileenslounge.com/viewtopic.php?f=30&t=30646" onclick="window.open(this.href);return false;
http://www.eileenslounge.com/viewtopic.php?f=30&t=30643" onclick="window.open(this.href);return false;
Best wishes,
Hans

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

that solution and that question was the first pasrt this is the second part
plz see the sample file once again i am highlighting the cells where we have paste the data by adding and subtracting
see sheet5 i have highlighted the cells
see sheet6 for the result
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78535
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Copy and paste of the data between sheets with add/subtr

Post by HansV »

Please study the code that I wrote for you, and try to modify it to do what you want.
Best wishes,
Hans

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

Oh i am so sorry HansV Sir, My mistake
Wasted ur precious time Sorry
Thnx HansV Sir for ur great great Support
Have a Great Day

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

HansV sir i tried to edit the code but i failed
Plz look into this problem

User avatar
Oliver
2StarLounger
Posts: 128
Joined: 08 Mar 2010, 13:53
Location: Missouri

Re: Copy and paste of the data between sheets with add/subtr

Post by Oliver »

Leonardo you should try a little harder...

Here is a variation of Hans' code.

Code: Select all

Sub CopyData()
    Dim w1 As Worksheet
    Dim w2 As Worksheet
    Dim w3 As Worksheet
    Dim r1 As Long
    Dim r3 As Long
    Dim m As Long
    Application.ScreenUpdating = False
    Set w1 = Worksheets("Sheet5")
    Set w2 = Worksheets("Sheet6")
    Set w3 = Worksheets("Sheet3")
    m = w3.Range("A" & w3.Rows.Count).End(xlUp).Row
    
    For r3 = 2 To m
        r1 = r1 + 1
        w2.Range("A1").EntireRow.Copy Destination:=w1.Range("A" & r1)
        w1.Range("C" & r1).Value = w3.Range("B" & r3).Value
        r1 = r1 + 1
        w2.Range("A3").EntireRow.Copy Destination:=w1.Range("A" & r1)
        w1.Range("G" & r1).Value = w3.Range("D" & r3).Value - 0.1
        w1.Range("L" & r1).Value = w3.Range("D" & r3).Value - 0.05
        w1.Range("C" & r1).Value = w3.Range("B" & r3).Value
    Next r3
    Set w3 = Worksheets("Sheet4")
    m = w3.Range("A" & w3.Rows.Count).End(xlUp).Row
    For r3 = 2 To m
        r1 = r1 + 1
        w2.Range("A2").EntireRow.Copy Destination:=w1.Range("A" & r1)
        w1.Range("C" & r1).Value = w3.Range("B" & r3).Value
        r1 = r1 + 1
        w2.Range("A4").EntireRow.Copy Destination:=w1.Range("A" & r1)
        w1.Range("G" & r1).Value = w3.Range("D" & r3).Value + 0.1
        w1.Range("L" & r1).Value = w3.Range("D" & r3).Value + 0.05
        w1.Range("C" & r1).Value = w3.Range("B" & r3).Value
    Next r3
    Application.ScreenUpdating = True
End Sub
Regards,
Oliver
“Just because something doesn't do what you planned it to do doesn't mean it's useless.” -Thomas Edison

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

Thnx Oliver for giving ur precious time and great support to this post
Problem Solved

User avatar
Oliver
2StarLounger
Posts: 128
Joined: 08 Mar 2010, 13:53
Location: Missouri

Re: Copy and paste of the data between sheets with add/subtr

Post by Oliver »

:thumbup:
Leonardo I encourage you to look into these links: 1, 2, 3, 4, 5.
These are awesome VBA training resources provided to me by HansV & Rudi.
Regards,
Oliver
“Just because something doesn't do what you planned it to do doesn't mean it's useless.” -Thomas Edison

leonardo1234
Banned
Posts: 233
Joined: 28 Jul 2018, 17:29

Re: Copy and paste of the data between sheets with add/subtr

Post by leonardo1234 »

Thnx Oliver, Rudi, HansV Sir for the info