好吧,所以我想,如果可行的話,想出了一個更好的解決方案。宏觀情況如何能像這樣做評論中的事情?用變化的單元格範圍循環所需的代碼
Sub CopyCombinationForLP()
' CopyCombinationForLP Macro
' Copy Combinations For Linear Programming Working And Copy Results in New Sheet
' Need this part to loop for a number of times depending on "cell value P1":
Sheets("Combinations Prior LP").Select
Range("P6:Z6").Select 'need this range to change +1 row every loop for a total of "cell value in P1" in sheet "Combination Prior LP
Selection.Copy
Sheets("Linear Programming Combination ").Select
Range("A1").Select 'Need this range stays the same for each loop
ActiveSheet.Paste Link:=True
Sheets("LP Combination 1 ").Select
Range("A2:G32").Select 'need this range to stay the same for each loop
Application.CutCopyMode = False
Selection.Copy
Sheets("Linear Programming Combination ").Select
Range("A2").Select 'Need this range to stay the same for each loop
ActiveSheet.Paste
Range("I10").Select 'This one stays the same foe every loop
Range("B32:E32").Select 'Need this range to stay the same for each loop
Application.CutCopyMode = False
Selection.Copy
Sheets("Linear Programming Results").Select
Range("A2").Select 'need this one to shift +1 row every loop
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Combinations Prior LP").Select
End Sub
我認爲這是一個可行的解決方案,因爲我只需要線性編程組合的結果表。最大的組合,我可以達到10000。 下面是鏈接的什麼,我試圖複製的截圖粘貼:
第一步: https://dl.dropboxusercontent.com/u/83126653/Combinations%20Prior%20LP.png
第二步: https://dl.dropboxusercontent.com/u/83126653/Linear%20Programming%20Combination.png
希望這有助於更多。請幫我
可insteresing:怎樣避免使用選擇/活動語句(http://stackoverflow.com/questions/10714251/excel-macro-avoiding-using-選擇) –
第三步: https://dl.dropboxusercontent.com/u/83126653/LP%20Combination%201.png Fouth步驟: https://dl.dropboxusercontent.com/u/83126653/Linear %20Programming%20Results.png –