Sub GLVlookup()
'
' GLVlookup Macro
' Macro recorded 31/03/2008 by pvo2
'
'
Range("E2:E60000").Select
Selection.Insert Shift:=xlToRight
Range("E2").Select
ActiveCell.FormulaR1C1 = "ID"
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = "=TRIM(RC[-3]&RC[-2]&RC[-1])"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
Cells.Find(What:="Currency", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "ID"
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = "=TRIM(RC[-3]&RC[-2]&RC[-1])"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
Cells.Find(What:="Currency", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(0, 1).Select
ActiveCell.FormulaR1C1 = "ID"
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = "=TRIM(RC[-3]&RC[-2]&RC[-1])"
ActiveCell.Offset(1, 0).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -1))
Cells.Find(What:="GL Region", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Cells.Find(What:="In Source Only", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-7],'Pivot Table'!R2C1:R382C5,2,FALSE)),0,VLOOKUP(RC[-7],'Pivot Table'!R2C1:R382C5,2,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-9],'Pivot Table'!R2C1:R382C5,3,FALSE)),0,VLOOKUP(RC[-9],'Pivot Table'!R2C1:R382C5,3,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-11],'Pivot Table'!R2C1:R382C5,4,FALSE)),0,VLOOKUP(RC[-11],'Pivot Table'!R2C1:R382C5,4,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-13],'Pivot Table'!R2C1:R382C5,5,FALSE)),0,VLOOKUP(RC[-13],'Pivot Table'!R2C1:R382C5,5,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-15],'Pivot Table'!R2C1:R382C5,6,FALSE)),0,VLOOKUP(RC[-15],'Pivot Table'!R2C1:R382C5,6,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-17],'Pivot Table'!R2C1:R382C5,7,FALSE)),0,VLOOKUP(RC[-16],'Pivot Table'!R2C1:R382C5,7,FALSE))"
ActiveCell.Offset(1, -10).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -6))
Cells.Find(What:="Group", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="In Source Only", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-7],'Pivot Table'!R2C1:R382C5,2,FALSE)),0,VLOOKUP(RC[-7],'Pivot Table'!R2C1:R382C5,2,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-9],'Pivot Table'!R2C1:R382C5,3,FALSE)),0,VLOOKUP(RC[-9],'Pivot Table'!R2C1:R382C5,3,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-11],'Pivot Table'!R2C1:R382C5,4,FALSE)),0,VLOOKUP(RC[-11],'Pivot Table'!R2C1:R382C5,4,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-13],'Pivot Table'!R2C1:R382C5,5,FALSE)),0,VLOOKUP(RC[-13],'Pivot Table'!R2C1:R382C5,5,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-15],'Pivot Table'!R2C1:R382C5,6,FALSE)),0,VLOOKUP(RC[-15],'Pivot Table'!R2C1:R382C5,6,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-17],'Pivot Table'!R2C1:R382C5,7,FALSE)),0,VLOOKUP(RC[-16],'Pivot Table'!R2C1:R382C5,7,FALSE))"
ActiveCell.Offset(1, -10).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -6))
Cells.Find(What:="External", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
Cells.Find(What:="In Source Only", After:=ActiveCell, LookIn:=xlFormulas, LookAt _
:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
ActiveCell.Offset(1, 0).Select
Do
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-7],'Pivot Table'!R2C1:R382C5,2,FALSE)),0,VLOOKUP(RC[-7],'Pivot Table'!R2C1:R382C5,2,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-9],'Pivot Table'!R2C1:R382C5,3,FALSE)),0,VLOOKUP(RC[-9],'Pivot Table'!R2C1:R382C5,3,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-11],'Pivot Table'!R2C1:R382C5,4,FALSE)),0,VLOOKUP(RC[-11],'Pivot Table'!R2C1:R382C5,4,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-13],'Pivot Table'!R2C1:R382C5,5,FALSE)),0,VLOOKUP(RC[-13],'Pivot Table'!R2C1:R382C5,5,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-15],'Pivot Table'!R2C1:R382C5,6,FALSE)),0,VLOOKUP(RC[-15],'Pivot Table'!R2C1:R382C5,6,FALSE))"
ActiveCell.Offset(0, 2).Select
ActiveCell.FormulaR1C1 = _
"=IF(ISNA(VLOOKUP(RC[-17],'Pivot Table'!R2C1:R382C5,7,FALSE)),0,VLOOKUP(RC[-16],'Pivot Table'!R2C1:R382C5,7,FALSE))"
ActiveCell.Offset(1, -10).Select
Loop Until IsEmpty(ActiveCell.Offset(0, -6))
End Sub
Bookmarks