2013-05-29 21 views
1

我使用excel表格。向單元格鍵入文本時複製表格

我需要設置什麼時候有人輸入文本到最後一個單元格,這樣excel會自動將整個表格複製到新列表中,以便繼續將下一個數據填充到新列表中。

對不起,但我是Excel初學者。我可能需要設置「IF」語句來啓動將表格複製到新列表的宏。但我不知道該怎麼做。

預先感謝每一個提示和建議

+0

任何文字或特定內容,如RUN_THIS什麼? Excel中的單元格是什麼? – Jim

回答

1

這個宏檢查,看是否A30RUN_THIS,如果它是副本A1通過A29該地區在B1開始。如果您希望其中的任何一個不同,您將不得不修改腳本。要創建宏,在表名(Sheet1)在電子表格的底部點擊右鍵並選擇View Code

Private Sub Worksheet_Change(ByVal Target As Range) 
    Dim KeyCells As Range 

    ' The variable KeyCells contains the cells that will 
    ' cause an alert when they are changed. 
    Set KeyCells = Range("A30:A30") 

    If Not Application.Intersect(KeyCells, Range(Target.Address)) _ 
      Is Nothing Then 

    ' This will check to see if cell A30 is equal to RUN_THIS and It then 
    ' copies the values from A1 through A29 to the space starting at B1 

    Worksheets("Sheet1").Range("A30").Select 

    If Worksheets("Sheet1").Range("A30").Value = "RUN_THIS" Then 
     Range("A1:A29").Select 
     Selection.Copy 
     Range("B1").Select 
     ActiveSheet.Paste 
     Range("D15").Select 
    End If 

    End If 
End Sub 
+0

@ user2166133如果您認爲可以接受,請點擊大面朝下的箭頭以接受此項。點擊向上箭頭並不表示您已接受它。謝謝! – Jim

+0

@ user2166133請點擊大的向下箭頭來「接受」這個。點擊向上箭頭並不表示您已接受它。謝謝! – Jim

相關問題