我有一个VBA脚本,该脚本当前可从excel复制数据并将其保存到记事本中,我面临的唯一问题是我无法将保存数限制为1000行,然后创建一个新的记事本进行保存接下来的1000,直到将整个数据集保存到不同的记事本中。
我尝试使用行计数,但是我无法针对重复出现的数据进行设置。
Sub Text_eob()
Dim ws As Worksheet
Dim s As String
Dim r As Range
Dim fldrname As String
Dim fldrpath As String
Dim fso As Object
Application.ScreenUpdating = False
Application.DisplayAlerts = False
Set ws = ThisWorkbook.Sheets("EOB")
Worksheets("EOB").Activate
With ws
Set rData = .Range(.Cells(2, 1), .Cells(.Rows.Count, 2).End(xlUp))
.Columns(.Columns.Count).Clear
s = ws.Name
ws.Range(.Cells(1, 1), .Cells(.Rows.Count, 2).End(xlUp)).Select
Sheets(s).Select
Sheets(s).Copy
tdate = Now()
Set fso = CreateObject("scripting.filesystemobject")
fldrname = Format(tdate, "dd-mm-yyyy")
fldrpath = "C:\Users\sasharat\Desktop\Lab_Upload\" & fldrname
If Not fso.folderexists(fldrpath) Then
fso.createfolder (fldrpath)
End If
fldrname = Format(tdate, "dd-mm-yyyy")
fldpath = "C:\Users\sasharat\Desktop\Lab_Upload\" & fldrname & "\"
ActiveWorkbook.SaveAs fldpath & (Format(Now, "mmddyyyy") & "-" & "EOB"), FileFormat:=xlText
Application.DisplayAlerts = True
ActiveWorkbook.Close savechanges:=False
ThisWorkbook.Activate
Worksheets("Lab_Upload").Activate
End With
End Sub
我希望将数据按1000行拆分为txt文件,直到完成整个数据集。