Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-25-2018, 04:28 PM
Dave T Dave T is offline Multiple worksheet lookup Windows 7 64bit Multiple worksheet lookup Office 2013
Advanced Beginner
Multiple worksheet lookup
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default Multiple worksheet lookup

Hello All,



I have two worksheets that I need a formula or a function to merge data from both worksheets into a third.
What I am trying to do is merge data associated with a specific structure (e.g. a bridge); for example in the worksheet called Merged Sheets I have highlighted two examples (also highlighted in other worksheets) of what I am trying to achieve:
• Data sourced from the BARRIER_RCS worksheet will be a straight lookup (so I am OK with this).
• For a unique Plan Number use the specific ROAD NO and specific RRD (Road Running Distance) to find the road number in the CURR_LANE_WIDTHS worksheet then find where the exact structures RRD sits within the START RRD and END RRD and return the various Lane Widths.

BARRIER_RCS
This worksheet contains data relating to a range of structures.
• Column A contains the plan number of a structure on a road (unique ID).
• Column B is the Road Number that the structure is on (there can be multiple structures on a road).
• Column C has the Road Running Distance (RRD) location of that structure (each structure will have a unique RRD).

CURR_LANE_WIDTHS
This worksheet contains physical data related to a variety of roads, i.e.
• Column A has the Road Number (note: a road number can be repeated multiple times).
• Column B has a Start RRD for a variety of road data between two RRD’s.
• Column C has the End RRD for each segment of road.
• Column D has the road Lane Width of the left lane.
• Column E has the road Lane Width of the inner left lane (if the road has two lane travelling in the same direction).
• Column F has the road lane width on the right lane.
• Column G has the road Lane Width of the inner right lane (if the road has two lane travelling in the same direction).

I hope this all makes sense, but if not please ask me to clarify.

Regards,
Dave T
Attached Files
File Type: xlsx Merged worksheets - To be posted.xlsx (40.7 KB, 9 views)
Reply With Quote
  #2  
Old 11-27-2018, 04:18 PM
p45cal's Avatar
p45cal p45cal is offline Multiple worksheet lookup Windows 10 Multiple worksheet lookup Office 2016
Expert
 
Join Date: Apr 2014
Posts: 867
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

Try Array-Entering (Ctrl+Shift+Enter, not just Enter) this formula in cell D2 of sheet Merged Sheets. Copy down and across.
Code:
=INDEX(CURR_LANE_WIDTHS!D$2:D$70,MIN(IF(((CURR_LANE_WIDTHS!$A$2:$A$70=$B2)*(CURR_LANE_WIDTHS!$B$2:$B$70<=$C2)*(CURR_LANE_WIDTHS!$C$2:$C$70>=$C2))>0,ROW(CURR_LANE_WIDTHS!$A$2:$A$70))))
It returns zero for where there are blank cells in CURR_LANE_WIDTHS, but you could wrap the whole formula in an IF statement to return a blank instead, if you're confident there are no lane widths of zero.
Reply With Quote
  #3  
Old 11-27-2018, 05:25 PM
Dave T Dave T is offline Multiple worksheet lookup Windows 7 64bit Multiple worksheet lookup Office 2013
Advanced Beginner
Multiple worksheet lookup
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default

Hello p45cal,

I really, really appreciate your reply.

I had found a post on Ozgrid that was most likely another solution:
https://www.ozgrid.com/forum/forum/h...ss-than-checks
But I was getting results that did not appear to be quite correct.

I also found problems when further researching the SUMPRODUCT formula:
- the formula needed to be on the same BARRIER_RCS worksheet and not the Merged Sheets worksheet.
- that column lengths for the ranges needed to be the same

Here is the formula I modified based on the formula in the attached worksheet from the Ozgrid site.
Code:
=IF(SUMPRODUCT(($B$2:$B$1015=$B145)*($C145>=CURR_LANE_WIDTHS!$B$2:$B$1015)*($C145<=CURR_LANE_WIDTHS!$C$2:$C$1015),ROW(CURR_LANE_WIDTHS!$D$2:$D$1015))=0,"",INDIRECT("CURR_LANE_WIDTHS!D"&SUMPRODUCT(($B$2:$B$1015=$B145)*($C145>=CURR_LANE_WIDTHS!$B$2:$B$1015)*($C145<=CURR_LANE_WIDTHS!$C$2:$C$1015),ROW(CURR_LANE_WIDTHS!$D$2:$D$1015))))
For copying the formula across I needed to change the column ID in the formula and the column number in the INDIRECT("CURR_LANE_WIDTHS!D"&SUMPRODUCT part as well.

I also played with the array formula posted by mikerickson but could not get it to work.

I must admit when I looked at the formula from the Ozgrid post I did not expect a reply to this post, so I really do appreciate your reply.

Regards,
Dave T
Reply With Quote
  #4  
Old 11-28-2018, 06:38 AM
p45cal's Avatar
p45cal p45cal is offline Multiple worksheet lookup Windows 10 Multiple worksheet lookup Office 2016
Expert
 
Join Date: Apr 2014
Posts: 867
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

The Ozgrid site appears down at the moment so I can't comment.
However: Does my offering give you the results you're looking for?
Reply With Quote
  #5  
Old 11-29-2018, 03:11 AM
Dave T Dave T is offline Multiple worksheet lookup Windows 7 64bit Multiple worksheet lookup Office 2013
Advanced Beginner
Multiple worksheet lookup
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default

Hello p45cal,

Sorry about the delay in getting back to you, but I thought I would re-run both options on a larger data set to see both options and compare the results.

The worksheet called Merged Sheets has your array formula in columns D to G.
The worksheet called BARRIER_RCS has the formula from the Ozgrid site.

In both worksheets I added data in columns J to P, that was copied from the CURR_LANE_WIDTHS worksheet to check the formula results against the expected results.
To ensure I had pasted the correct data I added a formula in column I, where 'In range' shows that the actual RRD is between the Start RRD and End RRD distances.

Unless I have made a mistake with both formulas you can see they do not match up.

It is looking like I will have to ask for one worksheet with all the values rather than do a complicated lookup.

Thanks for your help anyway.

Regards,
Dave T
Attached Files
File Type: xlsx Merged worksheets - Posted 29-11-2018.xlsx (127.3 KB, 9 views)
Reply With Quote
  #6  
Old 11-29-2018, 03:55 AM
p45cal's Avatar
p45cal p45cal is offline Multiple worksheet lookup Windows 10 Multiple worksheet lookup Office 2016
Expert
 
Join Date: Apr 2014
Posts: 867
p45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond reputep45cal has a reputation beyond repute
Default

my apologies, it was one row out.
Code:
=INDEX(CURR_LANE_WIDTHS!D$2:D$1015,MIN(IF(((CURR_LANE_WIDTHS!$A$2:$A$1015=$B2)*(CURR_LANE_WIDTHS!$B$2:$B$1015<=$C2)*(CURR_LANE_WIDTHS!$C$2:$C$1015>=$C2))>0,ROW(CURR_LANE_WIDTHS!$A$2:$A$1015)))-1)
(Added a -1 towards the end of the formula)


Where there are errors, you can IFERROR those out.
Reply With Quote
  #7  
Old 11-29-2018, 03:03 PM
Dave T Dave T is offline Multiple worksheet lookup Windows 7 64bit Multiple worksheet lookup Office 2013
Advanced Beginner
Multiple worksheet lookup
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default

Hello p45cal,

Just tried you addition to the formula and all is good.

I really do appreciate you time and effort.

Regards,
Dave T
Reply With Quote
  #8  
Old 12-02-2018, 09:56 PM
Dave T Dave T is offline Multiple worksheet lookup Windows 7 64bit Multiple worksheet lookup Office 2013
Advanced Beginner
Multiple worksheet lookup
 
Join Date: Nov 2014
Location: Australia
Posts: 66
Dave T is on a distinguished road
Default

Hello All,

I was showing a work colleague the formula from the Ozgrid post (in my second attachment) and he found out I had made a mistake.

The formula in columns D to G on the BARRIER_RCS worksheet should have been:
Code:
=IF(SUMPRODUCT((CURR_LANE_WIDTHS!$A$2:$A$1015=$B2)*($C2>=CURR_LANE_WIDTHS!$B$2:$B$1015)*($C2<=CURR_LANE_WIDTHS!$C$2:$C$1015),ROW(CURR_LANE_WIDTHS!$D$2:$D$1015))=0,"",INDIRECT("CURR_LANE_WIDTHS!D"&SUMPRODUCT((CURR_LANE_WIDTHS!$A$2:$A$1015=$B2)*($C2>=CURR_LANE_WIDTHS!$B$2:$B$1015)*($C2<=CURR_LANE_WIDTHS!$C$2:$C$1015),ROW(CURR_LANE_WIDTHS!$D$2:$D$1015))))
The column ID (in blue) will need to be changed each time as you drag the formula from column D to G.

Just thought I would post this followup as it is another alternative that is not an array formula.

Regards,
Dave T
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Multiple sheet lookup kevexcel Excel 0 06-27-2018 12:51 AM
Sum and Lookup multiple values coolkat Excel 1 11-06-2017 03:47 AM
Match multiple lookup values? tinfanide Excel 3 07-02-2017 05:35 AM
Formula help please (lookup across multiple sheets) froggybsb03 Excel 2 03-16-2017 02:16 AM
Multiple worksheet lookup How can I retreive multiple records using a lookup? jrpey Excel 3 11-14-2011 02:10 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft