我是一個總VBA noob,並一直在努力尋找解決方案,我正在努力實現。我可以在網上找到這些作品,但似乎無法將它們串在一起。真的很感謝一些幫助!VBA複製/粘貼動態行,頻率取決於列數
我有以下格式的源文件:
+------------+------------+----------+--------+--------+ | From | To | Job Type | Apples | Orange | +------------+------------+----------+--------+--------+ | 08/01/2015 | 14/01/2015 | Bought | 1 | 2 | | 08/01/2015 | 14/01/2015 | Sold | 3 | 4 | | 01/01/2015 | 07/01/2015 | Bought | 5 | 6 | | 01/01/2015 | 07/01/2015 | Sold | 7 | 8 | +------------+------------+----------+--------+--------+
我需要一個宏把它轉換成以下格式上的另一個工作表:
+------------+------------+----------+---------+-------+ | From | To | Job Type | Product | Count | +------------+------------+----------+---------+-------+ | 08/01/2015 | 14/01/2015 | Bought | Apples | 1 | | 08/01/2015 | 14/01/2015 | Sold | Apples | 3 | | 01/01/2015 | 07/01/2015 | Bought | Apples | 5 | | 01/01/2015 | 07/01/2015 | Sold | Apples | 7 | | 08/01/2015 | 14/01/2015 | Bought | Oranges | 2 | | 08/01/2015 | 14/01/2015 | Sold | Oranges | 4 | | 01/01/2015 | 07/01/2015 | Bought | Oranges | 6 | | 01/01/2015 | 07/01/2015 | Sold | Oranges | 8 | +------------+------------+----------+---------+-------+
然而,行數,列是動態的,例如下週「香蕉」也可能作爲產品出現,並且或者可能有更多的日期行。
所以我試圖複製行的動態範圍與發生次數取決於列的數量。
我真的很希望這是有道理的。任何幫助將非常感激。
在此先感謝!
道歉在回答延時按鈕,套上了在工作和週末的東西。非常感謝,這絕對是中途。但是,如果源文件包含附加列(例如香蕉),則不會將其複製到「擴展」工作表上。我認爲'COLUMNS_TO_MOVE'需要是所有非空列減去3個常數列的數量。再次感謝! – 2015-02-09 09:43:13