Great, so no modifications required for Excel 2010

The code below works for both 2003 and 2010

Sub Consolidator()

    Dim rngStart As Range
    Dim varArray As Range

    Application.ScreenUpdating = 0
    Range("F1").CurrentRegion.Clear
    With Cells.Find(What:="Machine", Lookat:=xlWhole,
searchDirection:=xlNext, After:=Cells(1))
    Set rngStart = Range(.Offset(1), .Offset(, 1).End(xlDown).Offset(, -1))
    End With
    On Error Resume Next
    rngStart.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=r[-1]c"
    Err.Clear: On Error GoTo -1: On Error GoTo 0
    With Range("F1")
        .Resize(rngStart.Rows.Count + 1, 2).Value =
rngStart(0).Resize(rngStart.Rows.Count + 1, 2).Value
        If Val(Application.Version) <= 11 Then
            .CurrentRegion.AdvancedFilter Action:=xlFilterInPlace,
Unique:=True
            .CurrentRegion.SpecialCells(xlCellTypeVisible).Copy
rngStart.Offset(rngStart.Rows.Count + 1)(1)
            .AutoFilter: .Parent.AutoFilterMode = 0
            .CurrentRegion.Clear
            With rngStart.Offset(rngStart.Rows.Count + 1)(1).CurrentRegion
                .Copy Range("F1"): .ClearContents
            End With
        Else
            .CurrentRegion.RemoveDuplicates Columns:=Array(1, 2),
Header:=xlYes
        End If
        .Offset(, 2).Resize(1, 2).Value = rngStart(0).Offset(, 2).Resize(1,
2).Value
        With .Offset(1, 2).Resize(.CurrentRegion.Rows.Count - 1, 2)
            .Formula = "=SUMPRODUCT(--(" & rngStart.Address & "=$F2),--(" &
rngStart.Offset(, 1).Address & "=$G2)," & rngStart.Offset(, 2).Address(1,
0) & ")"
            .Value = .Value
        End With
    End With
    On Error Resume Next
    rngStart.SpecialCells(xlCellTypeFormulas).ClearContents
    Err.Clear: On Error GoTo -1: On Error GoTo 0
    Application.ScreenUpdating = 1

End Sub

Regards,
Sam Mathai Chacko

On Mon, Nov 28, 2011 at 6:33 PM, Bé Trần Văn <betnmtdongna...@gmail.com>wrote:

>
>
> 2011/11/28 Sam Mathai Chacko <samde...@gmail.com>
>
>> Son, the macro is written for 2007-10. Will send a modified version,
>> but before that, can you confirm the result is correct in 2007-10? If
>> not, what is the issue?
>>
>> Sam
>>
>> On 28/11/2011, son nguyen <sonnguye...@gmail.com> wrote:
>> > Hi Mr Sam.
>> > I wonder this code used for which office as 2003,2007,2010.Because my
>> > office is 2003 and result  is not to like my desirement.
>> >
>> > Hope that you can feed back more to me
>> >
>> > Regards
>> > son
>> >
>> > 2011/11/27 Sam Mathai Chacko <samde...@gmail.com>
>> >
>> >> Here's a macro to get this done
>> >>
>> >> Sub Consolidator()
>> >>
>> >>     Dim rngStart As Range
>> >>
>> >>     Application.ScreenUpdating = 0
>> >>     Range("F1").CurrentRegion.Clear
>> >>     With Cells.Find(What:="Machine", Lookat:=xlWhole,
>> >> searchDirection:=xlNext, After:=Cells(1))
>> >>     Set rngStart = Range(.Offset(1), .Offset(, 1).End(xlDown).Offset(,
>> >> -1))
>> >>     End With
>> >>     On Error Resume Next
>> >>     rngStart.SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=r[-1]c"
>> >>     Err.Clear: On Error GoTo -1: On Error GoTo 0
>> >>     With Range("F1")
>> >>         .Resize(rngStart.Rows.Count + 1, 2).Value =
>> >> rngStart(0).Resize(rngStart.Rows.Count + 1, 2).Value
>> >>         .CurrentRegion.RemoveDuplicates Columns:=Array(1, 2),
>> >> Header:=xlYes
>> >>         .Offset(, 2).Resize(1, 2).Value = rngStart(0).Offset(,
>> >> 2).Resize(1, 2).Value
>> >>         With .Offset(1, 2).Resize(.CurrentRegion.Rows.Count - 1, 2)
>> >>             .Formula = "=SUMPRODUCT(--(" & rngStart.Address &
>> "=$F2),--("
>> >> & rngStart.Offset(, 1).Address & "=$G2)," & rngStart.Offset(,
>> >> 2).Address(1,
>> >> 0) & ")"
>> >>             .Value = .Value
>> >>         End With
>> >>     End With
>> >>     On Error Resume Next
>> >>     rngStart.SpecialCells(xlCellTypeFormulas).ClearContents
>> >>     Err.Clear: On Error GoTo -1: On Error GoTo 0
>> >>     Application.ScreenUpdating = 1
>> >>
>> >> End Sub
>> >>
>> >> Regards,
>> >>
>> >> Sam Mathai Chacko
>> >>
>> >>
>> >> On Sun, Nov 27, 2011 at 6:40 PM, rajan verma
>> >> <rajanverma1...@gmail.com>wrote:
>> >>
>> >>>  Hi
>> >>> Please see the attached file.. Pivot table can be used for this ..
>> >>>
>> >>> Regards
>> >>> Rajan
>> >>>
>> >>>  On Sat, Nov 26, 2011 at 8:23 PM, son nguyen
>> >>> <sonnguye...@gmail.com>wrote:
>> >>>
>> >>>> Dear all,
>> >>>>
>> >>>>
>> >>>> I have problem of calculating sheet.Detail as sheet attached.
>> >>>> I want to have a macro to sum value within qty, and downtime column
>> then
>> >>>> delete products are duplicated within each machine.
>> >>>>
>> >>>> I look foward to hear your help asap
>> >>>>
>> >>>>
>> >>>> Best Regards
>> >>>> Son
>> >>>>
>> >>>> --
>> >>>> FORUM RULES (934+ members already BANNED for violation)
>> >>>>
>> >>>> 1) Use concise, accurate thread titles. Poor thread titles, like
>> Please
>> >>>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need
>> Advice
>> >>>> will not get quick attention or may not be answered.
>> >>>>
>> >>>> 2) Don't post a question in the thread of another member.
>> >>>>
>> >>>> 3) Don't post questions regarding breaking or bypassing any security
>> >>>> measure.
>> >>>>
>> >>>> 4) Acknowledge the responses you receive, good or bad.
>> >>>>
>> >>>> 5) Cross-promotion of, or links to, forums competitive to this forum
>> in
>> >>>> signatures are prohibited.
>> >>>>
>> >>>> NOTE : Don't ever post personal or confidential data in a workbook.
>> >>>> Forum owners and members are not responsible for any loss.
>> >>>>
>> >>>>
>> >>>>
>> ------------------------------------------------------------------------------------------------------
>> >>>> To post to this group, send email to excel-macros@googlegroups.com
>> >>>>
>> >>>
>> >>>
>> >>>
>> >>> --
>> >>> Regards
>> >>> Rajan verma
>> >>> +91 9158998701
>> >>>
>> >>> --
>> >>> FORUM RULES (934+ members already BANNED for violation)
>> >>>
>> >>> 1) Use concise, accurate thread titles. Poor thread titles, like
>> Please
>> >>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need
>> Advice
>> >>> will not get quick attention or may not be answered.
>> >>>
>> >>> 2) Don't post a question in the thread of another member.
>> >>>
>> >>> 3) Don't post questions regarding breaking or bypassing any security
>> >>> measure.
>> >>>
>> >>> 4) Acknowledge the responses you receive, good or bad.
>> >>>
>> >>> 5) Cross-promotion of, or links to, forums competitive to this forum
>> in
>> >>> signatures are prohibited.
>> >>>
>> >>> NOTE : Don't ever post personal or confidential data in a workbook.
>> Forum
>> >>> owners and members are not responsible for any loss.
>> >>>
>> >>>
>> >>>
>> ------------------------------------------------------------------------------------------------------
>> >>> To post to this group, send email to excel-macros@googlegroups.com
>> >>>
>> >>
>> >>
>> >>
>> >> --
>> >> Sam Mathai Chacko
>> >>
>> >> --
>> >> FORUM RULES (934+ members already BANNED for violation)
>> >>
>> >> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> >> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> >> will not get quick attention or may not be answered.
>> >>
>> >> 2) Don't post a question in the thread of another member.
>> >>
>> >> 3) Don't post questions regarding breaking or bypassing any security
>> >> measure.
>> >>
>> >> 4) Acknowledge the responses you receive, good or bad.
>> >>
>> >> 5) Cross-promotion of, or links to, forums competitive to this forum in
>> >> signatures are prohibited.
>> >>
>> >> NOTE : Don't ever post personal or confidential data in a workbook.
>> Forum
>> >> owners and members are not responsible for any loss.
>> >>
>> >>
>> >>
>> ------------------------------------------------------------------------------------------------------
>> >> To post to this group, send email to excel-macros@googlegroups.com
>> >>
>> >
>> >
>> >
>> > --
>> > Best Regards
>> > Son
>> >
>> > --
>> > FORUM RULES (934+ members already BANNED for violation)
>> >
>> > 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> > Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will
>> > not get quick attention or may not be answered.
>> >
>> > 2) Don't post a question in the thread of another member.
>> >
>> > 3) Don't post questions regarding breaking or bypassing any security
>> > measure.
>> >
>> > 4) Acknowledge the responses you receive, good or bad.
>> >
>> > 5)  Cross-promotion of, or links to, forums competitive to this forum in
>> > signatures are prohibited.
>> >
>> > NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum
>> > owners and members are not responsible for any loss.
>> >
>> >
>> ------------------------------------------------------------------------------------------------------
>> > To post to this group, send email to excel-macros@googlegroups.com
>> >
>>
>> --
>> Sent from my mobile device
>>
>> Sam Mathai Chacko
>>
>> --
>> FORUM RULES (934+ members already BANNED for violation)
>>
>> 1) Use concise, accurate thread titles. Poor thread titles, like Please
>> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
>> will not get quick attention or may not be answered.
>>
>> 2) Don't post a question in the thread of another member.
>>
>> 3) Don't post questions regarding breaking or bypassing any security
>> measure.
>>
>> 4) Acknowledge the responses you receive, good or bad.
>>
>> 5)  Cross-promotion of, or links to, forums competitive to this forum in
>> signatures are prohibited.
>>
>> NOTE  : Don't ever post personal or confidential data in a workbook.
>> Forum owners and members are not responsible for any loss.
>>
>>
>> ------------------------------------------------------------------------------------------------------
>> To post to this group, send email to excel-macros@googlegroups.com
>>
>
> Using the PivotTable to sum up:
>
> Paste your data into the user below the title and run Macro by:
> From the menu, select Tools, select Macro, select Maco up theMacro dialog
> box, select RunPivotTable, rise to a new sheetnamed TONGHOPNhapDuLieu, by
> dragging and dropping your results sheet named TONGHOP
>
> --
> FORUM RULES (934+ members already BANNED for violation)
>
> 1) Use concise, accurate thread titles. Poor thread titles, like Please
> Help, Urgent, Need Help, Formula Problem, Code Problem, and Need Advice
> will not get quick attention or may not be answered.
>
> 2) Don't post a question in the thread of another member.
>
> 3) Don't post questions regarding breaking or bypassing any security
> measure.
>
> 4) Acknowledge the responses you receive, good or bad.
>
> 5) Cross-promotion of, or links to, forums competitive to this forum in
> signatures are prohibited.
>
> NOTE : Don't ever post personal or confidential data in a workbook. Forum
> owners and members are not responsible for any loss.
>
>
> ------------------------------------------------------------------------------------------------------
> To post to this group, send email to excel-macros@googlegroups.com
>



-- 
Sam Mathai Chacko

-- 
FORUM RULES (934+ members already BANNED for violation)

1) Use concise, accurate thread titles. Poor thread titles, like Please Help, 
Urgent, Need Help, Formula Problem, Code Problem, and Need Advice will not get 
quick attention or may not be answered.

2) Don't post a question in the thread of another member.

3) Don't post questions regarding breaking or bypassing any security measure.

4) Acknowledge the responses you receive, good or bad.

5)  Cross-promotion of, or links to, forums competitive to this forum in 
signatures are prohibited. 

NOTE  : Don't ever post personal or confidential data in a workbook. Forum 
owners and members are not responsible for any loss.

------------------------------------------------------------------------------------------------------
To post to this group, send email to excel-macros@googlegroups.com

Reply via email to