DataBlake
Well-known Member
- Joined
- Jan 26, 2015
- Messages
- 781
- Office Version
- 2016
- Platform
- Windows
So i have a nested formula that i would like to shorten or to convert to VBA
General info:
- I have a sheet containing part numbers in column A: sheet name "Unknown"
- I have 3 sheets containing information i need each with different part numbers. sheet names: 1,2,3
One of the 3 sheets contains the part number from "Unknown"
- I have a vlookup that looks in each sheet and then grabs the information i need
Problems:
- I have to add sheets in the future so i will have to go back and nest even more statements every time i add a sheet (4,5,6,7,etc)
- I will eventually hit a wall of maximum nested statements
- Its not pretty
how can i shorten this or turn it into a VBA macro that will sequence down a column until the end of a row?
ideas:
VBA using the sheetnames as a variant to create an array to search for the partnumber. Then use that row to grab the info from each column i need.
General info:
- I have a sheet containing part numbers in column A: sheet name "Unknown"
- I have 3 sheets containing information i need each with different part numbers. sheet names: 1,2,3
One of the 3 sheets contains the part number from "Unknown"
- I have a vlookup that looks in each sheet and then grabs the information i need
Problems:
- I have to add sheets in the future so i will have to go back and nest even more statements every time i add a sheet (4,5,6,7,etc)
- I will eventually hit a wall of maximum nested statements
- Its not pretty
Code:
=IF(Unknown!B2="new","1 New "&IFERROR(VLOOKUP(Unknown!A2,'1'!1:1048576,3,FALSE),IFERROR(VLOOKUP(Unknown!A2,'2'!1:1048576,3,FALSE),IFERROR(VLOOKUP(Unknown!A2,'3'!1:1048576,3,FALSE)&" "&IFERROR(VLOOKUP(Unknown!A2,'1'!1:1048576,4,FALSE),IFERROR(VLOOKUP(Unknown!A2,'2'!1:1048576,4,FALSE),IFERROR(VLOOKUP(Unknown!A2,'3'!1:1048576,4,FALSE),.......""))),""))))
how can i shorten this or turn it into a VBA macro that will sequence down a column until the end of a row?
ideas:
VBA using the sheetnames as a variant to create an array to search for the partnumber. Then use that row to grab the info from each column i need.
Last edited: