什么是最有效的方式来转置这个表的所有除了2列(如在这张图片)?

我想在Excel或Access中完成此操作 。 我需要find最有效的方法来做到这一点,否则我的用户不会一直这样做。 最终,我希望它是在最后的forms,以使查询在Access中,但我列出的Excel作为一个选项,因为我总是可以从电子表格导入到Access。

简而言之,我想转置除了前2列以外的每一列。 然后,我要为每个转置的行分配原始对应的itemdescription

我使用的方法是使用Excel中的转置粘贴复制和粘贴第3,4和5行,然后手动将每个项目和描述复制到相应的行,但这对于近400行和50列是不可行的我的用户将与之合作。

我有访问Access / VB的经验,Excel(但在这里没有VB的经验),和SQL。 我想find最快的方法来做到这一点。 我不介意build立查询或进入一些VB代码,我只是真的想这个工作。

在运行下面的代码之前,请删除列H到K中的所有数据。否则,代码将不起作用。

 Sub CreateTable() lastRow = Cells(Rows.Count, 1).End(xlUp).Row startRow = 2 lastCol = Cells(1, Columns.Count).End(xlToLeft).Column startCol = 3 counter = 2 For rowCnt = startRow To lastRow itemStr = Cells(rowCnt, 1).Value descStr = Cells(rowCnt, 2).Value For colCnt = startCol To lastCol dateStr = Cells(1, colCnt).Value qnty = Cells(rowCnt, colCnt).Value Cells(counter, 8).Value = itemStr Cells(counter, 9).Value = descStr Cells(counter, 10).Value = qnty Cells(counter, 11).Value = dateStr counter = counter + 1 Next Next Cells(1, 8).Value = "item" Cells(1, 9).Value = "description" Cells(1, 10).Value = "expected_qty" Cells(1, 11).Value = "expected_job_date" End Sub