Hi all,
I'm in need of some help. I have a workbook with two worksheets - Sheet A has (for simplicity) three columns with data in. Col A has a Location ID (this may be duplicated several times), Col B has a number in which relates to a depth, and Col C has a test number in. Sheet B has a table which I require auto completing with VBA. The header for the table is in Row 19. In col A and B in Sheet B I have a start depth and a base depth in Col B. The rest of the table requires the test values (from Col C in Sheet A) to be inserted.
The code needs to loop through each test value in Col C (Sheet A) and for each value, look at what the ID ref is (Col A) and the depth (Col B), and then copy this value into the correct cell in the table, using the corresponding ID ref in row 19 (Sheet B) to work out what col in the table to past to, and working out if the depth falls within the depth range in Col A and B (Sheet B) using basic math to work out what row to paste the value into.
Sheet A
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 106"]
<tbody>[TR]
[TD]Col A[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD]Col B[/TD]
[TD]Col C[/TD]
[/TR]
[TR]
[TD]WS1[/TD]
[TD]1[/TD]
[TD]45[/TD]
[/TR]
[TR]
[TD]WS1[/TD]
[TD]2[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]WS1[/TD]
[TD]4.5[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]WS2[/TD]
[TD]1[/TD]
[TD]15[/TD]
[/TR]
</tbody>[/TABLE]
Sheet B
[TABLE="width: 500"]
<tbody>[TR]
[TD]Top (on row 19)
Col A[/TD]
[TD]Base
Col B[/TD]
[TD]WS1
Col C[/TD]
[TD]WS2
Col D[/TD]
[TD]WS3
Col E[/TD]
[TD]BH1
Col F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1.99[/TD]
[TD]45[/TD]
[TD]15[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2.99[/TD]
[TD]50[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3.99[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4.99[/TD]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I hope the tables help! T
Thanks in advance.
I'm in need of some help. I have a workbook with two worksheets - Sheet A has (for simplicity) three columns with data in. Col A has a Location ID (this may be duplicated several times), Col B has a number in which relates to a depth, and Col C has a test number in. Sheet B has a table which I require auto completing with VBA. The header for the table is in Row 19. In col A and B in Sheet B I have a start depth and a base depth in Col B. The rest of the table requires the test values (from Col C in Sheet A) to be inserted.
The code needs to loop through each test value in Col C (Sheet A) and for each value, look at what the ID ref is (Col A) and the depth (Col B), and then copy this value into the correct cell in the table, using the corresponding ID ref in row 19 (Sheet B) to work out what col in the table to past to, and working out if the depth falls within the depth range in Col A and B (Sheet B) using basic math to work out what row to paste the value into.
Sheet A
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 106"]
<tbody>[TR]
[TD]Col A[/TD]
[/TR]
</tbody><colgroup><col></colgroup>[/TABLE]
[/TD]
[TD]Col B[/TD]
[TD]Col C[/TD]
[/TR]
[TR]
[TD]WS1[/TD]
[TD]1[/TD]
[TD]45[/TD]
[/TR]
[TR]
[TD]WS1[/TD]
[TD]2[/TD]
[TD]50[/TD]
[/TR]
[TR]
[TD]WS1[/TD]
[TD]4.5[/TD]
[TD]12[/TD]
[/TR]
[TR]
[TD]WS2[/TD]
[TD]1[/TD]
[TD]15[/TD]
[/TR]
</tbody>[/TABLE]
Sheet B
[TABLE="width: 500"]
<tbody>[TR]
[TD]Top (on row 19)
Col A[/TD]
[TD]Base
Col B[/TD]
[TD]WS1
Col C[/TD]
[TD]WS2
Col D[/TD]
[TD]WS3
Col E[/TD]
[TD]BH1
Col F[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]1.99[/TD]
[TD]45[/TD]
[TD]15[/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]2.99[/TD]
[TD]50[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3.99[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]4.99[/TD]
[TD]12[/TD]
[TD][/TD]
[TD][/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]
I hope the tables help! T
Thanks in advance.