Dear Weaver,
Thank u soo much for ur revert. Actually i am exactly doing the same as u have mentioned, due to the limited knowledge of excel macro that i have attaching the complete piece of the code for your views:
Basically, i am referring to multiple wrok books and slicing band dicing with pivoting then\ database to arrive the output.
Private Sub txtfilename_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
filetoopen = Application _
.GetOpenFilename("Excel files(*.*),*.xls")
If filetoopen <> False Then
txtfilename.Value = filetoopen
Workbooks.Open txtfilename.Value
'Change Worksheet Name
ActiveSheet.Name = "data"
'' Correct Account Number to 14 digits
Rows("1:1").Select
Selection.Find(What:="accNo", After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Font.Bold = True
ActiveCell.Offset(0, 1).Select
ActiveCell.EntireColumn.Insert
ActiveCell.Value = "Account No"
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = "=TEXT(RC[-1],""00000000000000"")"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, 1))
Selection.End(xlUp).Select
Selection.End(xlUp).Select
ActiveCell.Offset(1, 0).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.Copy
ActiveCell.Offset(0, -1).Select
Range(Selection, Selection.End(xlDown)).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
' Correct Product code field that is remove L from starting
Rows("1:1").Select
Selection.Find(What:="codProduct", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Font.Bold = True
ActiveCell.EntireColumn.Select
Selection.Replace What:="L", Replacement:="", LookAt:=xlPart, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _
ReplaceFormat:=False
'Consider Product Code flage at the right side of data
Rows("1:1").Select
Selection.Find(What:="codProduct", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.Font.Bold = True
ActiveCell.EntireColumn.Copy
ActiveCell.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Product Code"
ActiveCell.Font.Bold = True
ActiveCell.Offset(1, 0).Select
MsgBox ("Open Product Code File")
Prodcodefile = Application.GetOpenFilename("Excel Files(*.xls),*.xls")
Do
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-1],'[Approv Product Data.xls]Product Code'!c2,1,0)),0,1)"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, -1).Select
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
'Consider Amount Record flag
ActiveCell.Offset(0, 1).Select
Rows("1:1").Select
Selection.Find(What:="AmtCrMADB", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Copy
ActiveCell.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Consider AMT"
ActiveCell.Font.Bold = True
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=IF(RC[-1]<499999,0,1)"
ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Insert range of AmtcrMADB 5 Lac and 10 Lac
ActiveCell.Offset(0, 1).Select
ActiveCell.Font.Bold = True
ActiveCell.Value = "Range of CrMADB"
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-2]<0,""Less than Zero"",IF(RC[-2]<499999,""Less than 5L"",IF(RC[-2]<999999,""Greater than 5L"",""Greater than 10L"")))"
ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, -2).Select
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
'Consider LOB Flag for Sales, Branch, Privy
Rows("1:1").Select
Selection.Find(What:="CodSourcingLOB", LookAt:=xlWhole, _
SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False).Activate
ActiveCell.EntireColumn.Copy
ActiveCell.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
Selection.PasteSpecial Paste:=xlValues, _
Operation:=xlNone, SkipBlanks:=False, _
Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Consider LOB"
ActiveCell.Font.Bold = True
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=IF(OR(RC[-1]=51,RC[-1]=52,RC[-1]=55,RC[-1]=99),1,0)"
ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
' Insert Channel Type field update throght CodSourcingLOB Field
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Channel"
ActiveCell.Font.Bold = True
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-2]=51,""Branch"",IF(RC[-2]=52,""Sales"",IF(RC[-2]=55,""Privy"",""other"")))"
ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
ActiveCell.Offset(0, -2).Select
ActiveCell.EntireColumn.Select
Selection.Delete Shift:=xlToLeft
'Live Accounts Flag
ActiveCell.End(xlToRight).Select
ActiveCell.Offset(0, 1).Select
ActiveCell.Font.Bold = True
ActiveCell.Value = "Live"
ActiveCell.Offset(1, 0).Select
MsgBox ("Open Attritions File")
closefile = Application.GetOpenFilename("Excel Files(*.xls),*.xls")
Do
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-31],[Close.xls]Data!C6,1,0)),1,0)"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Consider Record Flag
ActiveCell.Offset(0, 1).Select
ActiveCell.Value = "Consider Record"
ActiveCell.Font.Bold = True
ActiveCell.Offset(1, 0).Select
ActiveCell.FormulaR1C1 = "=RC[-1]*RC[-3]*RC[-5]*RC[-6]"
ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Selection.End(xlUp)).Select
Selection.FillDown
ActiveCell.EntireColumn.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
'Pivot Code for Data2
Cells(1, 1).Select
Range(Selection, ActiveCell.SpecialCells(xlLastCell)).Select
Sheets.Add
ActiveWorkbook.PivotCaches.Create(SourceType:=xlDatabase, SourceData:= _
"data!R1C1:R5920C39", Version:=xlPivotTableVersion10).CreatePivotTable _
TableDestination:="Sheet1!R3C1", TableName:="PivotTable3", DefaultVersion _
:=xlPivotTableVersion10
Sheets("Sheet1").Select
With ActiveSheet.PivotTables("PivotTable3").PivotFields("CodBranch")
.Orientation = xlRowField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Consider Record")
.Orientation = xlPageField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Range of CrMADB")
.Orientation = xlColumnField
.Position = 1
End With
With ActiveSheet.PivotTables("PivotTable3").PivotFields("Channel")
.Orientation = xlColumnField
.Position = 2
End With
ActiveSheet.PivotTables("PivotTable3").AddDataField ActiveSheet.PivotTables( _
"PivotTable3").PivotFields("AccNo"), "Count of AccNo", xlCount
ActiveCell.Offset(12, 3).Range("A1").Select
With ActiveSheet.PivotTables("PivotTable3")
.NullString = "0"
.ShowDrillIndicators = False
End With
ActiveSheet.PivotTables("PivotTable3").PivotFields("Consider Record"). _
CurrentPage = "1"
ActiveSheet.Name = "Pivot1"
Sheets("Pivot1").Copy Before:=Sheets(1)
ActiveSheet.Name = "Data2"
Cells.Select
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Application.CutCopyMode = False
End If
Sheets("Data2").Activate
If ActiveCell.Range("C5").Value = "Sales" Then
ActiveCell.Range("c5").Select
ActiveCell.EntireColumn.Insert
ActiveCell.Value = "Privy"
End If
End Sub