各位大大,小弟的EXCEL突然無法複製工作表
本來是用VBA去複製到最後再改名字.代碼如下圖.結果他說無法複製.
之後我再建一個新檔,是可以複製的.
但是如果我運行過VBA就不行了(如下圖)另外我也試過在同一個XLM.內新建一個空白的工作表再複製是可以的,但我填入資料後就不行了,這是什麼問題呢?求各位幫忙.謝謝
我才開始接觸VBA,很多資料都是一個個的慢慢填.我在想如果我有一組東西要填的應該怎樣寫.
如:worksheets(1)的V4至AZ4要填到worksheets(2)的B13至AF13
worksheets(1)的BB4至CF4要填到worksheets(2)的B14至AF14
偵錯後黃標了這句
Worksheets(2).Copy after:=Sheets(Sheets.Count)
Sub fillup()
Worksheets(1).Range("B4").Activate
Dim name As String
Dim sex As String
Dim NRID As Double
Dim BD As Date
Dim Telno As String
Dim position As String
Dim joindate As Date
Dim otS As Double
Dim RDOS As Double
Dim SHS As Double
Dim other As String
Dim Salary As Double
Dim allowance As Double
Do Until ActiveCell = ""
name = Worksheets(1).Range(ActiveCell, ActiveCell).Value
sex = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 1).Value
BD = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 2).Value
NRID = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 3).Value
Telno = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 4).Value
position = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 5).Value
joindate = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 6).Value
Salary = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 7).Value
allowance = Worksheets(1).Range(ActiveCell, ActiveCell).Offset(0, 8).Value
Worksheets(2).Range("e6") = name
Worksheets(2).Range("e7") = NRID
Worksheets(2).Range("o7") = Telno
Worksheets(2).Range("ab6") = BD
Worksheets(2).Range("ab7") = position
Worksheets(2).Range("ab8") = joindate
Worksheets(2).Range("z23") = Salary
Worksheets(2).Range("z24") = allowance
Worksheets(2).Copy after:=Sheets(Sheets.Count)
Sheets(Sheets.Count).name = name
Worksheets(1).Activate
ActiveCell.Offset(1, 0).Select
Loop
End Sub