码迷,mamicode.com
首页 > 其他好文 > 详细

数据按列拆分(可选择)

时间:2020-02-06 01:32:01      阅读:66      评论:0      收藏:0      [点我收藏+]

标签:int   for   count   选择   set   after   each   offset   ksh   

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

数据按列拆分(可选择)

标签:int   for   count   选择   set   after   each   offset   ksh   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!