Sub Macro1() Dim sht, NewSht As Worksheet Dim myName As String Dim i As Integer On Error Resume Next For i = 2 To Sheet2.[a65536].End(xlUp).Row myName = Sheet2.Cells(i, 1).Value Set NewSht = ThisWorkbook.Sheets(myName) If NewSht Is Nothing Then Set NewSht = ActiveWorkbook.Sheets.Add NewSht.Name = myName Sheet3.Cells.Copy NewSht.[a1] NewSht.[b3] = Sheet2.Cells(i, 2) NewSht.[e3] = Sheet2.Cells(i, 3) NewSht.[b4] = Sheet2.Cells(i, 4) NewSht.[g3] = Sheet2.Cells(i, 5) NewSht.[e4] = Sheet2.Cells(i, 6) NewSht.[g4] = Sheet2.Cells(i, 7) NewSht.[d5] = Sheet2.Cells(i, 8) NewSht.[b5] = Sheet2.Cells(i, 9) NewSht.[f5] = Sheet2.Cells(i, 10) NewSht.[h5] = Sheet2.Cells(i, 11) Else
Sheet3.Cells.Copy NewSht.[a1] NewSht.[b3] = Sheet2.Cells(i, 2) NewSht.[e3] = Sheet2.Cells(i, 3) NewSht.[b4] = Sheet2.Cells(i, 4) NewSht.[g3] = Sheet2.Cells(i, 5) NewSht.[e4] = Sheet2.Cells(i, 6) NewSht.[g4] = Sheet2.Cells(i, 7) NewSht.[d5] = Sheet2.Cells(i, 8) NewSht.[b5] = Sheet2.Cells(i, 9) NewSht.[f5] = Sheet2.Cells(i, 10) NewSht.[h5] = Sheet2.Cells(i, 11) End If Next End Sub
[此贴子已经被作者于2007-9-9 12:22:41编辑过] |