使用vba转换数据表的结构

我正试图使用​​vba将Excel中的现有数据表(表1)转换为新的数据表(表2)。 数据表示一个活动列表和相应的前辈,我希望它是在2列而不是多个。 如何将表1转换为表2?

Table 1: Table 2: AA BABA CBACB DCA EADCEA ED EC 

在这里input图像说明

在这里输入图像说明

我会做这样的事情(伪代码):

 int n = 2 // operator for tracking your row index for i = 1 to end of rows for j = 2 to end of column if cell(i,j) == empty do nothing else copy cell(1, i) to new table location (column 6, now n) copy cell(j, i) to new table location (column 7, row n) n = n+1 end end end 

请注意第6列和第7列是指新表的位置。