VBA copying values from multiple sheets

epactheactor

New Member
Joined
Sep 9, 2015
Messages
38
Hello!

I'm studying VBA and actually trying to get a degree in programming so every chance I get to practice at work with code, I do so.

I've come up with something I want to do, but can't get my head around HOW to do it.

On Workbook 1 (called "Line" as an example), I would have 2 columns with one being Start and the other End (columns D & E). These would a path in feet for inspection.
Also on this sheet, there would be a section for the information on who and when they did the inspection on different parts of the line (A1:C4).

Example;

[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]1[/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Inspector ID section[/TD]
[TD]Name[/TD]
[TD]Date[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]A[/TD]
[TD]Joe[/TD]
[TD]5/1/2019[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]G[/TD]
[TD]Dana[/TD]
[TD]6/5/2016[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD][/TD]
[TD][/TD]
[TD]Inspected by[/TD]
[TD]To (feet)[/TD]
[TD]From (feet)[/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD][/TD]
[TD][/TD]
[TD]A[/TD]
[TD]0[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD][/TD]
[TD][/TD]
[TD]G[/TD]
[TD]7[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD][/TD]
[TD][/TD]
[TD]A[/TD]
[TD]50[/TD]
[TD]62[/TD]
[/TR]
[TR]
[TD]10[/TD]
[TD][/TD]
[TD][/TD]
[TD]A[/TD]
[TD]62[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]11[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]13[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Now to make this harder, the Inspector ID information (A1:C4) comes from a different workbook called "Inspector ID". It is presented like this;
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD]Inspector Info[/TD]
[TD]Name[/TD]
[TD]Date Inspected (newest - oldest)[/TD]
[TD]Inspected To (feet)[/TD]
[TD]Inspected From (feet)[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Joe[/TD]
[TD]5/1/2019[/TD]
[TD]0[/TD]
[TD]7[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Joe[/TD]
[TD]5/1/2019[/TD]
[TD]50[/TD]
[TD]62[/TD]
[/TR]
[TR]
[TD]A[/TD]
[TD]Joe[/TD]
[TD]5/1/2019[/TD]
[TD]62[/TD]
[TD]100[/TD]
[/TR]
[TR]
[TD]D[/TD]
[TD]Dana[/TD]
[TD]6/5/2016[/TD]
[TD]7[/TD]
[TD]50[/TD]
[/TR]
</tbody>[/TABLE]


I've created a code that puts the Inspector ID section (range A2:C4) information into workbook "Line" from workbook "Inspector ID." After it does, I've been manually filling out the "Inspected By" (C6:C10) section.

My question is, how would I go about filling out the "Inspected By" column in "Line"? It would have to reference the "Inspector ID" workbook to see the footages of who did which.

I would think I would need to create each Inspector info as an array/index, then compare the To and From.

Any help would be greatly appreciated.
 

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.
How about


Excel 2013/2016
ABCDE
1Inspector ID sectionNameDate
2AJoe05/01/2019
3GDana06/05/2016
4
5Inspected byTo (feet)From (feet)
6A07
7D750
8A5062
9A62100
Sheet1
Cell Formulas
RangeFormula
C6{=INDEX(Sheet2!$A$2:$A$5,MATCH(1,(Sheet2!$D$2:$D$5=D6)*(Sheet2!$E$2:$E$5=E6),0))}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Hi! Sorry for such a late reply. I wanted to thank you for trying. The Index formula was a great idea. The issue with it was that the values of location are not always perfect matched and more often than not there is overlap. I did manage somehow manage to go write the code that I need.

Thanks for your help.
 
Upvote 0
Glad you sorted it & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,223,768
Messages
6,174,411
Members
452,562
Latest member
Himeshwari

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top