Combine rows, add values in spec. column

keffokenneth

New Member
Joined
Apr 26, 2021
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have just started with VBA and I need your help. I've attached a picture and I will try to explain my problem. In "lastat"-sheet, I will add stock/pallets that I will move to another warehouse. With "Move"-button i move numbers to "Lagersaldo"-sheet. This warehouse will use "Lagersaldo"-sheet as a inventory and also withdrawing after expedition. But we usually send same batches and i want these similar rows to be combined in . If D, E and L is the same, add these rows F value. Then delete the empty rows. I also want the updated information to be written over the old, not beside. The "I" column has "not full pallets" and I need to leave these as is; therefor I have a rand formula in L. I've tried to find a similar macro to solve this, but I cannot tweak these to my needs. I don't want to use a pivot, just vba. Please tell me if you guys have a solution or maybe need more information.

Best regards.
Joel
 

Attachments

  • Capture2.JPG
    Capture2.JPG
    177 KB · Views: 15

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.
Hi,​
as you already have answers on another forum so read forums rules about cross posting and do the necessary​
(links of other forums in each forum) …​
 
Upvote 0
Here is the code
VBA Code:
Sub TransferData()
Dim LR As Long, TR As Long, TA As Long, TB As Long, X As Long

Range("N4:V5").Value = Range("D4:L5").Value
LR = Range("D" & Rows.Count).End(xlUp).Row
X = 5
For TR = 6 To LR
    
    For TA = 5 To X
    If Range("D" & TR).Value = Range("N" & TA).Value And Range("E" & TR).Value = Range("O" & TA).Value And Range("L" & TR).Value = Range("V" & TA).Value Then
    Range("P" & TA).Value = Range("P" & TA).Value + Range("F" & TR).Value
    Range("Q" & TA).Value = Range("Q" & TA).Value + Range("G" & TR).Value
    Range("R" & TA).Value = Range("R" & TA).Value + Range("H" & TR).Value
    Range("S" & TA).Value = Range("S" & TA).Value + Range("I" & TR).Value
    Range("T" & TA).Value = Range("T" & TA).Value + Range("J" & TR).Value
    Range("U" & TA).Value = Range("U" & TA).Value + Range("K" & TR).Value
    'X = X + 1
    Enty = "Y"
    Exit For
    Else
    Enty = "N"
    End If
    Next TA
If Enty = "N" Then
X = X + 1
 Range("N" & X & ":V" & X).Value = Range("D" & TR & ":L" & TR).Value
End If
Next TR
End Sub
 
Upvote 0
Welcome to the MrExcel Message Board!

Cross-posting (posting the same question in more than one forum) is not against our rules, but the method of doing so is covered by #13 of the Forum Rules.

Be sure to follow & read the link at the end of the rule too!

Cross posted at: Combine and sum rows
If you have posted the question at more places, please provide links to those as well.

If you do cross-post in the future and also provide links, then there shouldn’t be a problem.
 
Upvote 0

Forum statistics

Threads
1,223,630
Messages
6,173,454
Members
452,514
Latest member
cjkelly15

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top