SAQIBN
New Member
- Joined
- Oct 16, 2021
- Messages
- 20
- Office Version
- 2013
- Platform
- Windows
I have recorded a Macro for a Workbook having 8 sheets!
Macro is with Following Steps.
1: wherever I'm in sheets, Goto Sheet1
2: From Sheet1 to Sheet8, Assign Name Range to Specific 3 Columns B:D
3: Insert a New Sheet in Start With name: "Vlookup"
4: In "Vlookup" Sheet , Draw Formula :
Recorded macro is as below:
But Error "can't execute code in break mode"
Macro is with Following Steps.
1: wherever I'm in sheets, Goto Sheet1
2: From Sheet1 to Sheet8, Assign Name Range to Specific 3 Columns B:D
3: Insert a New Sheet in Start With name: "Vlookup"
4: In "Vlookup" Sheet , Draw Formula :
Recorded macro is as below:
VBA Code:Sub ATL_VLOOKUP() ' ' ATL_VLOOKUP Macro ' ' Worksheets("Part1").Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE1", RefersToR1C1:="=Part1!C2:C4" ActiveWorkbook.Names("TABLE1").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE2", RefersToR1C1:="=Part2!C2:C4" ActiveWorkbook.Names("TABLE2").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE3", RefersToR1C1:="=Part3!C2:C4" ActiveWorkbook.Names("TABLE3").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Range("B1").Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE4", RefersToR1C1:="=Part4!C2:C4" ActiveWorkbook.Names("TABLE4").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE5", RefersToR1C1:="=Part5!C2:C4" ActiveWorkbook.Names("TABLE5").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE6", RefersToR1C1:="=Part6!C2:C4" ActiveWorkbook.Names("TABLE6").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE7", RefersToR1C1:="=Part7!C2:C4" ActiveWorkbook.Names("TABLE7").Comment = "" ActiveSheet.Next.Select Selection.End(xlUp).Select Columns("B:D").Select ActiveWorkbook.Names.Add Name:="TABLE8", RefersToR1C1:="=Part8!C2:C4" ActiveWorkbook.Names("TABLE8").Comment = "" Sheets.Add(before:=Sheets("Part1")).Name = "Vlookup" Worksheets("Vlookup").Activate ActiveCell.FormulaR1C1 = _ "=IFERROR(VLOOKUP(RC[-1],TABLE1,2,0),IFERROR(VLOOKUP(RC[-1],TABLE2,2,0),IFERROR(VLOOKUP(RC[-1],TABLE3,2,0),IFERROR(VLOOKUP(RC[-1],TABLE4,2,0),IFERROR(VLOOKUP(RC[-1],TABLE5,2,0),IFERROR(VLOOKUP(RC[-1],TABLE6,2,0),IFERROR(VLOOKUP(RC[-1],TABLE7,2,0),IFERROR(VLOOKUP(RC[-1],TABLE8,2,0),""NOT FOUND""))))))))" ActiveCell.FormulaR1C1 = _ "=IFERROR(VLOOKUP(RC[-2],TABLE1,3,0),IFERROR(VLOOKUP(RC[-2],TABLE2,3,0),IFERROR(VLOOKUP(RC[-2],TABLE3,3,0),IFERROR(VLOOKUP(RC[-2],TABLE4,3,0),IFERROR(VLOOKUP(RC[-2],TABLE5,3,0),IFERROR(VLOOKUP(RC[-2],TABLE6,3,0),IFERROR(VLOOKUP(RC[-2],TABLE7,3,0),IFERROR(VLOOKUP(RC[-2],TABLE8,3,0),""NOT FOUND""))))))))" Range("C3").Select End Sub