数据按列拆分(可选择)

Sub shi()
Dim i, k, l As Integer
Dim sht As Worksheet
irow = Sheet1.Range("a65536").End(xlUp).Row

l = InputBox("input name plase")

For i = 2 To irow
k = 0
For Each sht In Sheets
If sht.Name = Sheet1.Cells(i, l) Then
Sheet1.Cells(i, l).EntireRow.Copy sht.Range("a65536").End(xlUp).Offset(1, 0)
k = 1
End If
Next

If k = 0 Then
Sheets.Add after:=Sheets(Sheets.Count)
Sheets(Sheets.Count).Name = Sheet1.Cells(i, l)
Sheet1.Range("a1").EntireRow.Copy Sheets(Sheets.Count).Range("a1")
Sheet1.Cells(i, l).EntireRow.Copy Sheets(Sheets.Count).Range("a65536").End(xlUp).Offset(1, 0)
End If

Next
End Sub

原文地址:https://www.cnblogs.com/lyzifan/p/12267310.html