如何实现一键excel里的数据自动成每3000个一个新表?
发布网友
发布时间:2022-06-09 17:17
我来回答
共2个回答
热心网友
时间:2024-02-06 02:13
将你 要拆分的工作表放到单独文件夹,打开附件启用宏,点击按钮,选择主表,会在目录下生成。
Private Sub CommandButton1_Click()
f = Application.GetOpenFilename("CSV文件,*.csv")
If f <> False Then
Open f For Binary As #1
s = StrConv(InputB(LOF(1), 1), vbUnicode)
Close #1
s = "," & vbCrLf & s
ar = Split(s, vbCrLf)
f = Left(f, InStrRev(f, "\"))
For i = 1 To UBound(ar) Step 1
If InStr(ar(i), ",") > 0 Then
a = a & Left(ar(i), InStr(ar(i), ",") - 1) & vbCrLf
Else
a = a & ar(i)
End If
If (i Mod 3000) = 0 Then
n = n + 1
Open f & n & ".csv" For Output As #1
Print #1, a
Close #1
a = ""
End If
Next
If (i - 1 Mod 3000) <> 0 Then
Open f & n + 1 & ".csv" For Output As #1
Print #1, a
Close #1
End If
End If
MsgBox "完成"
End Sub
追问非常感谢!
热心网友
时间:2024-02-06 02:13
扣
一五九六三九七零追问什么意思?
追答
好吧。直接附件传上来——你需要启用宏。