- 帖子
- 150
- 主題
- 40
- 精華
- 0
- 積分
- 215
- 點名
- 0
- 作業系統
- windows xp
- 軟體版本
- sp3
- 閱讀權限
- 20
- 註冊時間
- 2013-7-15
- 最後登錄
- 2025-5-26
|
程式編寫完後,設定按鈕,指定巨集,指定巨集時,
會出現 "參照來源必須是巨集表" 的錯誤訊息
不知是設定上有問題 ? 還是程式碼有問題 ?
請教高手大大要如何解決! 謝謝感恩
程式碼如下
Dim x
Sub b1()
'
' b1 b
'每月資料整理程序
x = InputBox("年月") '欄位名稱
If Mid(x, 4, 1) = 1 Then
x1 = Mid(x, 4, 2)
Else
x1 = Mid(x, 5, 1)
End If
x2 = x1
x1 = x1 & "月"
x2 = x2 & "月排名"
Call b11
Sheets(x1).Select
Call b12
Sheets(x2).Select
Call b12
MsgBox "新增完成"
End Sub
Sub b11()
'yoy分析資料整理
Application.ScreenUpdating = False '停止螢幕更新以加快速度
Sheets("yoy分析").Select
'x = InputBox("年月") '首欄名稱
y = Cells(1, 1).End(xlToRight).Column '找最後一欄資料
Z = Cells(1, y).End(xlDown).Row '找最後一列資料
Cells(1, y + 1) = x
Range(Cells(2, y), Cells(Z, y)).Copy Range(Cells(2, y + 1), Cells(Z, y + 1))
Range(Cells(2, y), Cells(Z, y)).Copy
Cells(2, y).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False '選擇性貼上值
End Sub
Sub b12()
'月排名資料整理
'x = InputBox("年月") '首欄名稱
y = Cells(1, 1).End(xlToRight).Column '找最後一欄資料
Z = Cells(1, y).End(xlDown).Row '找最後一列資料
Cells(1, y + 1) = x
Range(Cells(2, y), Cells(Z, y)).Copy Range(Cells(2, y + 1), Cells(Z, y + 1))
Range(Cells(2, y), Cells(Z, y)).Copy
Cells(2, y).Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False '選擇性貼上值
End Sub |
|