URGENT!! Need help and some advice/reference.

zeecharle

New Member
Joined
Aug 26, 2015
Messages
20
Hi, Good Day!

Can anyone help me in my excel work.

I Have 1 excel file that Has multiple worksheet. The first worksheet is my master worksheet/ the summary worksheet. and the other worksheet is the worksheet that contains multiple data that are in same format/template. I want to gather all of the data from the multiple worksheet to the master/summary worksheet.

I will consider the duplicate data in different worksheet and it should add the quantity of the duplicate data.

My workbook is an inventory workbook.

Thank you for helping and your time.

-Zee
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
Can you just confirm the following is correct...

both sheets have exactly identical columns ITEM, SPECIFICATIONS & MAKER

Sheet 01-00 Total Quantity figures go into LH
Sheet 02-00 Total Quantity figures go into RH
The Total column is the total of LH & RH
 
Upvote 0
Can you just confirm the following is correct...

both sheets have exactly identical columns ITEM, SPECIFICATIONS & MAKER

Sheet 01-00 Total Quantity figures go into LH
Sheet 02-00 Total Quantity figures go into RH
The Total column is the total of LH & RH


PARTS LIST TEMPLATE(REVISED TEMPLATE FOR EACH SHEET)

Above is the link of my revised template for each worksheet.
And the expected result for the summary.

Thank you!
 
Upvote 0
Had a bit of a nightmare with this because of your extensive use of merged cells, most of these I have changed to center across selection. Please if you are going to use code, don't use merged cells.

Because of the above test the code below on a copy of your workbook. Make sure the sheets codename Sheet1, Sheet2 & Sheet4 are correct for your workbook (look in the properties window for your sheetname (which is in brackets), the codename is the name outside the brackets).

Run the transferit macro

Thanks to Erik Van Geit for the code that I have butchered yet again below.

Code:
Sub transferit()
    Dim ws As Worksheet, cRng As Range, i As Long, j As Long
    Application.ScreenUpdating = False

Call Unmerge_CenterAcross
For j = 1 To 3
    For i = 5 To 7
   
        With Sheets(j).Columns(i)
            .TextToColumns Destination:=.Cells(1, 1), FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True
        End With
    Next
Next
    With Sheet4.Range("B9:D" & Sheet4.Range("B" & Rows.Count).End(xlUp).Row)
        Sheet1.Range("B3").Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With

    With Sheet4.Range("G9:G" & Sheet4.Range("G" & Rows.Count).End(xlUp).Row)
        Sheet1.Range("E3").Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With

    With Sheet3.Range("G9:G" & Sheet3.Range("G" & Rows.Count).End(xlUp).Row)
        Sheet1.Range("F3").Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With
    Sheet1.Range("G3:G" & Sheet1.Range("F" & Rows.Count).End(xlUp).Row).NumberFormat = 0

    For Each cRng In Sheet1.Range("G3:G" & Sheet1.Range("F" & Rows.Count).End(xlUp).Row)
        cRng = Application.WorksheetFunction.Sum(cRng.Offset(, -2), cRng.Offset(, -1))
    Next
    Sheet1.Range("A1:A2,B1:B2,C1:C2,D1:D2,G1:G2").Merge
    For j = 2 To 3
    Sheets(j).Range("A1:G2").Merge
    Sheets(j).Range("C5").HorizontalAlignment = xlCenter
    Next
    Application.ScreenUpdating = True

End Sub
Sub Unmerge_CenterAcross()
'adapted from Erik Van Geit
'080808
 
'merged cells will be unmerged
'contents will be centered across merged area
 
Dim lr As Long, LC As Long, i As Long, j As Long, icnt As Long
Dim cntUnmerged As Long, cntMerged As Long, mergeRng As Range
Dim checkmerged As Boolean, LastMerged As String
 
Dim AppSetCalc As Integer, StatusBarVisible As Boolean
 
Dim msg As String, MaxRc As Long, ColorMe As Boolean
 
 
For icnt = 1 To 3
    With Sheets(icnt)
    'needing xlCellTypeLastCell: else if last cell is merged wrong area will be found
    lr = .Cells.Find(what:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
    LC = .Cells.Find(what:="*", SearchOrder:=xlColumns, SearchDirection:=xlPrevious, LookIn:=xlValues).Column
        With .Cells(lr, LC)
            If .MergeCells Then
            lr = lr + .MergeArea.Rows.Count - 1
            LC = LC + .MergeArea.Columns.Count - 1
            End If
        End With
    If .Range(.Cells(1, 1), .Cells(lr, LC)).MergeCells = False Then
    MsgBox "no merged cells on this sheet", 48, "EXIT"
    Exit Sub
    End If
 
    MaxRc = 5
    ColorMe = 0
 
    With Application
    .ScreenUpdating = False
    AppSetCalc = .Calculation
    .Calculation = xlCalculationManual
    StatusBarVisible = .DisplayStatusBar
    .DisplayStatusBar = True
    .EnableCancelKey = xlErrorHandler
    End With
 
    For i = 1 To lr
    On Error Resume Next
    checkmerged = .Range(.Cells(i, 1), .Cells(i, LC)).MergeCells
    'error occurs when MergeArea intersects row and contains more rows
    'checkmerged is TRUE when MergeArea is in one row
        If Err Or checkmerged Then
        Err.Clear
            For j = 1 To LC
                With .Cells(i, j)
                    If .Resize(1, 1).MergeCells Then
                    cntMerged = cntMerged + 1
                        On Error GoTo stopit
                        With .MergeArea
                            If .Rows.Count <= MaxRc Then
                            cntUnmerged = cntUnmerged + 1
                            .UnMerge
                            .HorizontalAlignment = xlCenterAcrossSelection
                            If ColorMe Then .Interior.ColorIndex = 3
                            Else
                            LastMerged = .Address(0, 0)
                            End If
                        End With
                    End If
                End With
            Next j
        End If
    Application.StatusBar = "rows checked: " & Round(i / lr, 2) * 100 & "%"
    Next i
 
    End With
Next
stopit:
    With Application
    .EnableCancelKey = xlDisabled
    .ScreenUpdating = True
    .Calculation = AppSetCalc
    .StatusBar = False
    .DisplayStatusBar = StatusBarVisible
    End With
 

End Sub
 
Upvote 0
Had a bit of a nightmare with this because of your extensive use of merged cells, most of these I have changed to center across selection. Please if you are going to use code, don't use merged cells.

Because of the above test the code below on a copy of your workbook. Make sure the sheets codename Sheet1, Sheet2 & Sheet4 are correct for your workbook (look in the properties window for your sheetname (which is in brackets), the codename is the name outside the brackets).

Run the transferit macro

Thanks to Erik Van Geit for the code that I have butchered yet again below.

Code:
Sub transferit()
    Dim ws As Worksheet, cRng As Range, i As Long, j As Long
    Application.ScreenUpdating = False

Call Unmerge_CenterAcross
For j = 1 To 3
    For i = 5 To 7
   
        With Sheets(j).Columns(i)
            .TextToColumns Destination:=.Cells(1, 1), FieldInfo:=Array(1, 1), TrailingMinusNumbers:=True
        End With
    Next
Next
    With Sheet4.Range("B9:D" & Sheet4.Range("B" & Rows.Count).End(xlUp).Row)
        Sheet1.Range("B3").Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With

    With Sheet4.Range("G9:G" & Sheet4.Range("G" & Rows.Count).End(xlUp).Row)
        Sheet1.Range("E3").Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With

    With Sheet3.Range("G9:G" & Sheet3.Range("G" & Rows.Count).End(xlUp).Row)
        Sheet1.Range("F3").Resize(.Rows.Count, .Columns.Count).Value = .Value
    End With
    Sheet1.Range("G3:G" & Sheet1.Range("F" & Rows.Count).End(xlUp).Row).NumberFormat = 0

    For Each cRng In Sheet1.Range("G3:G" & Sheet1.Range("F" & Rows.Count).End(xlUp).Row)
        cRng = Application.WorksheetFunction.Sum(cRng.Offset(, -2), cRng.Offset(, -1))
    Next
    Sheet1.Range("A1:A2,B1:B2,C1:C2,D1:D2,G1:G2").Merge
    For j = 2 To 3
    Sheets(j).Range("A1:G2").Merge
    Sheets(j).Range("C5").HorizontalAlignment = xlCenter
    Next
    Application.ScreenUpdating = True

End Sub
Sub Unmerge_CenterAcross()
'adapted from Erik Van Geit
'080808
 
'merged cells will be unmerged
'contents will be centered across merged area
 
Dim lr As Long, LC As Long, i As Long, j As Long, icnt As Long
Dim cntUnmerged As Long, cntMerged As Long, mergeRng As Range
Dim checkmerged As Boolean, LastMerged As String
 
Dim AppSetCalc As Integer, StatusBarVisible As Boolean
 
Dim msg As String, MaxRc As Long, ColorMe As Boolean
 
 
For icnt = 1 To 3
    With Sheets(icnt)
    'needing xlCellTypeLastCell: else if last cell is merged wrong area will be found
    lr = .Cells.Find(what:="*", SearchOrder:=xlRows, SearchDirection:=xlPrevious, LookIn:=xlValues).Row
    LC = .Cells.Find(what:="*", SearchOrder:=xlColumns, SearchDirection:=xlPrevious, LookIn:=xlValues).Column
        With .Cells(lr, LC)
            If .MergeCells Then
            lr = lr + .MergeArea.Rows.Count - 1
            LC = LC + .MergeArea.Columns.Count - 1
            End If
        End With
    If .Range(.Cells(1, 1), .Cells(lr, LC)).MergeCells = False Then
    MsgBox "no merged cells on this sheet", 48, "EXIT"
    Exit Sub
    End If
 
    MaxRc = 5
    ColorMe = 0
 
    With Application
    .ScreenUpdating = False
    AppSetCalc = .Calculation
    .Calculation = xlCalculationManual
    StatusBarVisible = .DisplayStatusBar
    .DisplayStatusBar = True
    .EnableCancelKey = xlErrorHandler
    End With
 
    For i = 1 To lr
    On Error Resume Next
    checkmerged = .Range(.Cells(i, 1), .Cells(i, LC)).MergeCells
    'error occurs when MergeArea intersects row and contains more rows
    'checkmerged is TRUE when MergeArea is in one row
        If Err Or checkmerged Then
        Err.Clear
            For j = 1 To LC
                With .Cells(i, j)
                    If .Resize(1, 1).MergeCells Then
                    cntMerged = cntMerged + 1
                        On Error GoTo stopit
                        With .MergeArea
                            If .Rows.Count <= MaxRc Then
                            cntUnmerged = cntUnmerged + 1
                            .UnMerge
                            .HorizontalAlignment = xlCenterAcrossSelection
                            If ColorMe Then .Interior.ColorIndex = 3
                            Else
                            LastMerged = .Address(0, 0)
                            End If
                        End With
                    End If
                End With
            Next j
        End If
    Application.StatusBar = "rows checked: " & Round(i / lr, 2) * 100 & "%"
    Next i
 
    End With
Next
stopit:
    With Application
    .EnableCancelKey = xlDisabled
    .ScreenUpdating = True
    .Calculation = AppSetCalc
    .StatusBar = False
    .DisplayStatusBar = StatusBarVisible
    End With
 

End Sub


Thanks for the code. It works for me. But I Have a question, what if I Have more than 2 worksheet? Because sometime it will be 20 sheet excluded the summary sheet in 1 excel file.

Sorry for the merged cells. I'm very sorry for that thing. I revised my template. Now it has no merged cells.

And please consider the sheets if more than 2 or more. Thank you very much for your help brother.

More power.

I already make it 4 sheets with different data. SO please check it. Thank you Very much.

PARTS LIST TEMPLATE(REVISED NO MERGED CELLS)

-Zee
 
Upvote 0
It works for me. But I Have a question, what if I Have more than 2 worksheet? Because sometime it will be 20 sheet excluded the summary sheet in 1 excel file.

What you do first of all is you make it very clear in the first post and not use phrases like "and the other worksheet" as it can make a big difference to the approach taken to the problem (as in your case).

Unfortunately I do not have as much time today to work on problems as I will be flitting in and out of the forum.

I will have a look at it if no-one else has but it is very unlikely to be today.
 
Upvote 0
What you do first of all is you make it very clear in the first post and not use phrases like "and the other worksheet" as it can make a big difference to the approach taken to the problem (as in your case).

Unfortunately I do not have as much time today to work on problems as I will be flitting in and out of the forum.

I will have a look at it if no-one else has but it is very unlikely to be today.


Okay. Thank you for the time. Im sorry for the wrong and unclear post of mine. But I will wait for your reference work.

I will search for more code about this case. Thank you again brother. More power.

-Zee
 
Upvote 0
Had a bit of time before a meeting, test on a copy of your workbook as only mildly tested.
Btw I haven't done anything about the sort order on the Summary sheet as I can't see a pattern.


Rich (BB code):
Sub zeecharle()
    Dim sht As Worksheet, LstRw As Long

    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With

    Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Working"

    For Each sht In ActiveWorkbook.Worksheets
     sht.Unprotect
        If sht.Name <> "Working" And sht.Name <> "SUMMARY" Then
            With sht.Range("B8:F" & sht.Range("B" & Rows.Count).End(xlUp).Row)
                Sheets("Working").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
            End With
        End If
    Next

    With Sheets("Working")
        .Range("A1:G1") = Array("PART NAME", "SPECIFICATIONS", "MAKER", "LH", "RH", "LH2", "RH2")

    End With
    With Sheets("Working")

        LstRw = .Range("A" & Rows.Count).End(xlUp).Row

        .Range("F2").Formula = "=SUMIFS(D2:D" & LstRw & ",A2:A" & LstRw & ",A2,B2:B" & LstRw & ",B2)"
        .Range("F2").AutoFill Destination:=.Range("F2:F" & LstRw), Type:=xlFillDefault

        .Range("G2").Formula = "=SUMIFS(E2:E" & LstRw & ",A2:A" & LstRw & ",A2,B2:B" & LstRw & ",B2)"
        .Range("G2").AutoFill Destination:=.Range("G2:G" & LstRw), Type:=xlFillDefault

        .Range("H2").Formula = "=SUM(F2:G2)"
        .Range("H2").AutoFill Destination:=.Range("H2:H" & LstRw), Type:=xlFillDefault

        .Calculate
        .Range("F2:H" & LstRw).Value = .Range("F2:H" & LstRw).Value
        .Range("D2:E" & LstRw).Delete shift:=xlToLeft

        .Range("B1:B" & LstRw).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
                                              .Range("B1:B" & LstRw), Unique:=True
        .Range("A2:F" & LstRw).SpecialCells(xlCellTypeVisible).Copy
        Sheets("SUMMARY").Range("B3").PasteSpecial Paste:=xlPasteValues

        With Application
            .CutCopyMode = False
            .DisplayAlerts = False
        End With

        .Delete

        With Application
            .DisplayAlerts = True
            .Calculation = xlCalculationAutomatic
            .Goto Sheets("Summary").Cells(1, 1), scroll:=True
            .ScreenUpdating = True
        End With
  
  End With
  
  For Each sht In ActiveWorkbook.Worksheets
     sht.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
  Next

End Sub
 
Last edited:
Upvote 0
Had a bit of time before a meeting, test on a copy of your workbook as only mildly tested.
Btw I haven't done anything about the sort order on the Summary sheet as I can't see a pattern.


Rich (BB code):
Sub zeecharle()
    Dim sht As Worksheet, LstRw As Long

    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With

    Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Working"

    For Each sht In ActiveWorkbook.Worksheets
     sht.Unprotect
        If sht.Name <> "Working" And sht.Name <> "SUMMARY" Then
            With sht.Range("B8:F" & sht.Range("B" & Rows.Count).End(xlUp).Row)
                Sheets("Working").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
            End With
        End If
    Next

    With Sheets("Working")
        .Range("A1:G1") = Array("PART NAME", "SPECIFICATIONS", "MAKER", "LH", "RH", "LH2", "RH2")

    End With
    With Sheets("Working")

        LstRw = .Range("A" & Rows.Count).End(xlUp).Row

        .Range("F2").Formula = "=SUMIFS(D2:D" & LstRw & ",A2:A" & LstRw & ",A2,B2:B" & LstRw & ",B2)"
        .Range("F2").AutoFill Destination:=.Range("F2:F" & LstRw), Type:=xlFillDefault

        .Range("G2").Formula = "=SUMIFS(E2:E" & LstRw & ",A2:A" & LstRw & ",A2,B2:B" & LstRw & ",B2)"
        .Range("G2").AutoFill Destination:=.Range("G2:G" & LstRw), Type:=xlFillDefault

        .Range("H2").Formula = "=SUM(F2:G2)"
        .Range("H2").AutoFill Destination:=.Range("H2:H" & LstRw), Type:=xlFillDefault

        .Calculate
        .Range("F2:H" & LstRw).Value = .Range("F2:H" & LstRw).Value
        .Range("D2:E" & LstRw).Delete shift:=xlToLeft

        .Range("B1:B" & LstRw).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
                                              .Range("B1:B" & LstRw), Unique:=True
        .Range("A2:F" & LstRw).SpecialCells(xlCellTypeVisible).Copy
        Sheets("SUMMARY").Range("B3").PasteSpecial Paste:=xlPasteValues

        With Application
            .CutCopyMode = False
            .DisplayAlerts = False
        End With

        .Delete

        With Application
            .DisplayAlerts = True
            .Calculation = xlCalculationAutomatic
            .Goto Sheets("Summary").Cells(1, 1), scroll:=True
            .ScreenUpdating = True
        End With
  
  End With
  
  For Each sht In ActiveWorkbook.Worksheets
     sht.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
  Next

End Sub


Hi There Brother,

Thank you for the Code and for the time to help me with this problem. It work in the case that I want it to and expected.

Ill try to find codes for the sorting.

The sorting goes like this, MAKER = DESCENDING and SPECIFICATION = ASCENDING.

So all of the same maker sort together before the next maker. and about the specification it sort as ASC. It is OK?

Your help is VERY MUCH APPRECIATED.

Thank you very much brother.

More power to you and in this forum!

-Zee
 
Upvote 0
Be careful....untested

Rich (BB code):
Sub zeecharle()
    Dim sht As Worksheet, LstRw As Long

    With Application
        .ScreenUpdating = False
        .Calculation = xlCalculationManual
    End With

    Worksheets.Add(After:=Worksheets(Worksheets.Count)).Name = "Working"

    For Each sht In ActiveWorkbook.Worksheets
        sht.Unprotect
        If sht.Name <> "Working" And sht.Name <> "SUMMARY" Then
            With sht.Range("B8:F" & sht.Range("B" & Rows.Count).End(xlUp).Row)
                Sheets("Working").Range("A" & Rows.Count).End(xlUp).Offset(1).Resize(.Rows.Count, .Columns.Count).Value = .Value
            End With
        End If
    Next

    With Sheets("Working")
        .Range("A1:G1") = Array("PART NAME", "SPECIFICATIONS", "MAKER", "LH", "RH", "LH2", "RH2")
        .Columns("A:F").AutoFit

    End With
    With Sheets("Working")

        LstRw = .Range("A" & Rows.Count).End(xlUp).Row

        .Range("F2").Formula = "=SUMIFS(D2:D" & LstRw & ",A2:A" & LstRw & ",A2,B2:B" & LstRw & ",B2)"
        .Range("F2").AutoFill Destination:=.Range("F2:F" & LstRw), Type:=xlFillDefault

        .Range("G2").Formula = "=SUMIFS(E2:E" & LstRw & ",A2:A" & LstRw & ",A2,B2:B" & LstRw & ",B2)"
        .Range("G2").AutoFill Destination:=.Range("G2:G" & LstRw), Type:=xlFillDefault

        .Range("H2").Formula = "=SUM(F2:G2)"
        .Range("H2").AutoFill Destination:=.Range("H2:H" & LstRw), Type:=xlFillDefault

        .Calculate
        .Range("F2:H" & LstRw).Value = .Range("F2:H" & LstRw).Value
        .Range("D2:E" & LstRw).Delete shift:=xlToLeft

        .Range("B1:B" & LstRw).AdvancedFilter Action:=xlFilterInPlace, CriteriaRange:= _
                                              .Range("B1:B" & LstRw), Unique:=True
        .Range("A2:F" & LstRw).SpecialCells(xlCellTypeVisible).Copy
        Sheets("SUMMARY").Range("B3").PasteSpecial Paste:=xlPasteValues

        With Application
            .CutCopyMode = False
            .DisplayAlerts = False
        End With

        .Delete

    End With

    With Sheets("SUMMARY")
        .Range("B3:G" & LstRw).Sort Key1:=.Range("D3"), Order1:=xlDescending, _
                                    Key2:=.Range("C3"), Order2:=xlAscending, Header:=xlNo

    End With
    With Application
        .DisplayAlerts = True
        .Calculation = xlCalculationAutomatic
        .Goto Sheets("SUMMARY").Cells(1, 1), scroll:=True
        .ScreenUpdating = True
    End With



    For Each sht In ActiveWorkbook.Worksheets
        sht.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
    Next


End Sub
 
Upvote 0

Forum statistics

Threads
1,215,770
Messages
6,126,794
Members
449,337
Latest member
BBV123

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