看板 Office 關於我們 聯絡資訊
(若是和其他不同軟體互動之問題 請記得一併填寫) 軟體: excel 版本: 2003 Sub 練習() Sheet1.Select i = 2 Do i = i + 1 Loop Until Cells(i, 9) = "" SheetLen = i - 1 Cells(2, 1).Formula = "=C2&""-""&D2" Range(Cells(2, 1)).Select Selection.AutoFill Destination:=Range(Cells(SheetLen, 1)) Cells(1, 1).Select End Sub 以上程式碼是我練習寫的,但是怎跑都卡在Range(Cells(2, 1)).Select 或是卡到在Selection.AutoFill Destination:=Range(Cells(SheetLen, 1)) 然後錯誤碼為1004 global物件失敗? 但是我這是參考寫出來一模一樣查不出錯誤在哪? 需麻煩解答了 謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.127.156.65
soyoso:range(cells(2,1)).select改Cells(2, 1).Select 03/23 20:26
soyoso:另一個destination的範圍改 Range(Selection, Cells(SheetL 03/23 20:27
soyoso:en, 1)) 03/23 20:27
coolair:destination改了後有錯誤訊息 03/23 20:37
soyoso:http://goo.gl/88SqIS 這是檔案,測試沒有問題 03/23 20:42
soyoso:可以的話,請原po提供檔案 03/23 20:42
coolair:奇怪了 我用我excel跑就會有1004的錯誤 03/23 20:46
soyoso:這要看一下原po的檔案了 03/23 20:47
coolair:重開機後SO大的巨集又正常了 03/23 21:04
soyoso:^^ 03/23 21:14
coolair:請問為什麼要多加上Selection才行? 03/23 21:22
soyoso:http://goo.gl/5UFYq6 官網說明 03/23 21:25
soyoso:The destination must include the source range 03/23 21:26
soyoso:目標範圍要包含本身要進行自動填滿的儲存格 03/23 21:27