|
楼主 |
发表于 2024-4-22 16:56
|
显示全部楼层
本帖最后由 mznz 于 2024-4-22 17:34 编辑
Dim nums, Name As String
Dim Fast As Integer
Application.ScreenUpdating = False
ActiveWorkbook.Worksheets("Sheet1").Range("$A$1:$K$1000000").RemoveDuplicates Columns:=Array(1, 2, 3), Header _
:=xlYes
ActiveWorkbook.Worksheets("Sheet1").Columns("A:A").Select
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Clear
ActiveWorkbook.Worksheets("Sheet1").Sort.SortFields.Add Key:=Range("A1"), _
SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With ActiveWorkbook.Worksheets("Sheet1").Sort
.SetRange Range("A2:I1000000")
.Header = xlNo
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
Worksheets("Sheet1").Select
Max_Row = Range("a1048576").End(xlUp).Row
Max_Col = Worksheets("Sheet1").UsedRange.Columns.Count
Application.ScreenUpdating = True
For Row = 2 To Max_Row
Name = Cells(Row, 1).Value
nums = Cells(Row, 2).Value
Fast = Cells(Row, 3).Value
Name = Worksheets("Sheet1").Cells(Row, 1)
lastname = Worksheets("Sheet1").Cells(Row - 1, 1)
Filename = Name & ".log"
If Name <> lastname Then
On Error Resume Next
txtFile.Writeline "wait 2"
On Error Resume Next
txtFile.Close
On Error Resume Next
FSO.Close
Set FSO = CreateObject("Scripting.FileSystemObject")
Set txtFile = FSO.CreateTextFile(ThisWorkbook.Path & "/test/" & Name, True)
txtFile.Writeline "wait 200"
txtFile.Writeline "for test "
For i = 1 To nums
txtFile.Writeline "add test=" & Fast(i) & "-100"
txtFile.Writeline "a " & Fast(i)
txtFile.Writeline ""
Next i
'上面的代码会根据每一行都生成一遍,想实现的是相同的Fast值,只生成一遍
'比如name1对应的Fast 400 只生成一次
|
|