'是不是個意思? 試試看:
'請貼到關的工作頁上
Private Sub Worksheet_Change(ByVal Target As Range)
Dim Rng As Range
If Target.Count > 1 Then Exit Sub
If Target <> [A1] And Target <> [A2] Then Exit Sub
If Target = [A2] And [A2] = -1 Then
[B2:K2401] = "A"
ElseIf Target = [A1] And [A1] > 1 Then
[B2:K2401] = "" '舊資料要不要清除? 如不清除請將這列註解掉
Set Rng = [B$1:K$1]
Rng.Copy Rng.Offset([A1] - 1, 0)
End If
End Sub作者: lucky12345 時間: 2016-1-13 16:57
'改用兩個按鈕試試看!!
'跟 [A6] 有關嗎? 依[A1] 或 [A6] 指定列, 貼上第一列的值?
'下列係依[A1]指定列, 貼上第一列的值
Private Sub CommandButton1_Click()
Dim Rng As Range, Lst As Integer
If [A1] > 1 Then
Set Rng = [B$1:K$1]
Rng.Copy
Rng.Offset([A1] - 1, 0).PasteSpecial Paste:=xlPasteValues '只貼上值, 公式格式等不會貼上
End If
End Sub
'用'A'覆蓋或全部清除
Private Sub CommandButton2_Click()
If [A2] = -1 Then
'下列二選一, 不要用到的, 請在前面加 '
'
[B2:K2401] = "A" '全部用'A'覆蓋
' [B2:K2401] = "" '全部清除
End If
End Sub作者: lucky12345 時間: 2016-1-14 19:53
1.Sorry, 忘了請你刪除上次 Worksheet_Change(自動執行) 的VBA
Private Sub Worksheet_Change(ByVal Target As Range)
...
End Sub
2.『sheet2!A1 不接受sheet1G12計數(數值) 無法自動複製 只能用手動輸入 數字 按Enter 才會複製一次』
ANS:所以才改用按鈕, 手動啟動下列VBA
Private Sub CommandButton1_Click()
Dim Rng As Range, Lst As Integer
If [A1] > 1 Then
Set Rng = [B$1:K$1]
Rng.Copy
Rng.Offset([A1] - 1, 0).PasteSpecial Paste:=xlPasteValues '只貼上值, 公式格式等不會貼上
End If
End Sub
3. 連[A2]=-1也改成手動, 所以要兩個按鈕
4. 你 9# 的VBA連試試都沒試吧!!