我的問題是如何使用VB宏重新排列電子表格。 CSV電子表格是我們的客戶的訂單,它是從他們的運輸軟件中導出的,需要上傳到運輸軟件中執行。Excel - 宏可通過更改電子表格動態重新排列列,行
在我非常基本的VB理解中遇到的問題是我用來嘗試寫這個的極端冗餘。我知道如何刪除行,列等。我不知道該怎麼做才能讓它變成動態變化的電子表格(三月份的IE 20訂單,四月份的40份訂單)
基本上需要發生什麼電子表格是前10行將需要刪除,您將需要保持行11和12,然後從那裏,你可以看到有名稱,如行12「外套和尾巴」,布萊斯Dishongh,地址,等跨越行。這些是需要保存在電子表格中的唯一行,它們每14或15行取決於。
我正在經歷這些只是倒數多少,並刪除行堆疊這些特定的行,但你可以看到多餘的編碼是。
有沒有更好的解決方案,可以根據每月有多少訂單來動態更改?
我使用的代碼是:
Sub Delete()
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Rows(1).EntireRow.Delete
Columns(1).EntireColumn.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(3).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(4).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(5).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(6).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(7).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(8).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
Rows(9).EntireRow.Delete
End Sub
正如你可以看到這是非常多餘。無論如何要清理這個?
如果您顯示您當前嘗試的代碼並討論一下,您將有更多的機會獲得幫助。 –