sangsterexcell
New Member
- Joined
- Dec 11, 2014
- Messages
- 11
I have this macro I found that is very close to what I have however I have a couple of extra columns. I need to combine my column D and add the totals in F, G and H. The information from the rest of the columns A.B,C and E just need to have the information shown.
This is the macro below I found that combined columns A and added D,E and F. What changes need to be made?
Sub MergeData()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
i = 2
LR = Range("A" & Rows.Count).End(xlUp).Row
Do
IFind = Cells(i, 1)
sAmt = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("D:D"))
sAmt2 = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("E:E"))
sAmt3 = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("F:F"))
Cells(i, 4) = sAmt
Cells(i, 5) = sAmt2
Cells(i, 6) = sAmt3
SR = Cells(i + 1, 1).Address(False, False)
Range("A:A").AutoFilter Field:=1, Criteria1:="=" & IFind
x = WorksheetFunction.CountIf(Range("A:A"), Range("A" & i))
If x > 1 Then
Range(SR & ":A" & LR).EntireRow.Delete
End If
Range("A:A").AutoFilter
i = i + 1
LR = Range("A" & Rows.Count).End(xlUp).Row
If LR = i Then GoTo 0
Loop Until IsEmpty(Cells(i, 1))
This is the macro below I found that combined columns A and added D,E and F. What changes need to be made?
Sub MergeData()
Dim LR As Long, i As Long
Application.ScreenUpdating = False
i = 2
LR = Range("A" & Rows.Count).End(xlUp).Row
Do
IFind = Cells(i, 1)
sAmt = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("D:D"))
sAmt2 = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("E:E"))
sAmt3 = WorksheetFunction.SumIf(Range("A:A"), IFind, Range("F:F"))
Cells(i, 4) = sAmt
Cells(i, 5) = sAmt2
Cells(i, 6) = sAmt3
SR = Cells(i + 1, 1).Address(False, False)
Range("A:A").AutoFilter Field:=1, Criteria1:="=" & IFind
x = WorksheetFunction.CountIf(Range("A:A"), Range("A" & i))
If x > 1 Then
Range(SR & ":A" & LR).EntireRow.Delete
End If
Range("A:A").AutoFilter
i = i + 1
LR = Range("A" & Rows.Count).End(xlUp).Row
If LR = i Then GoTo 0
Loop Until IsEmpty(Cells(i, 1))