Hello,
I have data in Sheet1 that I'd like to copy into Sheet2 based on the header. I'd like to create some kind of text array that I can update in the code to include new columns if they become relevant. I'd like the relevant headers array to be something like
sWords = {"Date", "Qty", "Method"}.
Then I can add new words if I need to (Example: sWords = {"Date", "Qty", "Method", "Quality"}).
I would like the words in the sWords array to be the search criteria for copy and paste. The words could be searched for in Sheet1 Row 1. I'm sure there is a way to do this with a For Loop or something but I am new to VBA.
In Sheet1, I have the data below.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Date
[/TD]
[TD]Qty[/TD]
[TD]Complete[/TD]
[TD]Method[/TD]
[TD]Quality[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1/5/18[/TD]
[TD]25[/TD]
[TD]Yes[/TD]
[TD]1[/TD]
[TD]High[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3/10/19[/TD]
[TD]10[/TD]
[TD]N[/TD]
[TD]2[/TD]
[TD]Medium[/TD]
[/TR]
</tbody>[/TABLE]
I'd like to be able to copy the headers in the sWord array and paste it into Sheet2.
For example, in the code, if I set sWord = {"Qty", "Method"}
I'd like Sheet2 to display the table below
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Qty
[/TD]
[TD]Method
[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]25[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]10[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
I hope I explained this well enough. I'd appreciate any help! Thanks!
I have data in Sheet1 that I'd like to copy into Sheet2 based on the header. I'd like to create some kind of text array that I can update in the code to include new columns if they become relevant. I'd like the relevant headers array to be something like
sWords = {"Date", "Qty", "Method"}.
Then I can add new words if I need to (Example: sWords = {"Date", "Qty", "Method", "Quality"}).
I would like the words in the sWords array to be the search criteria for copy and paste. The words could be searched for in Sheet1 Row 1. I'm sure there is a way to do this with a For Loop or something but I am new to VBA.
In Sheet1, I have the data below.
[TABLE="class: grid, width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[TD]C[/TD]
[TD]D[/TD]
[TD]E[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Date
[/TD]
[TD]Qty[/TD]
[TD]Complete[/TD]
[TD]Method[/TD]
[TD]Quality[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]1/5/18[/TD]
[TD]25[/TD]
[TD]Yes[/TD]
[TD]1[/TD]
[TD]High[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]3/10/19[/TD]
[TD]10[/TD]
[TD]N[/TD]
[TD]2[/TD]
[TD]Medium[/TD]
[/TR]
</tbody>[/TABLE]
I'd like to be able to copy the headers in the sWord array and paste it into Sheet2.
For example, in the code, if I set sWord = {"Qty", "Method"}
I'd like Sheet2 to display the table below
[TABLE="class: grid, width: 200"]
<tbody>[TR]
[TD][/TD]
[TD]A[/TD]
[TD]B[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Qty
[/TD]
[TD]Method
[/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]25[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]10[/TD]
[TD]2[/TD]
[/TR]
</tbody>[/TABLE]
I hope I explained this well enough. I'd appreciate any help! Thanks!