|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub RunF()
- Dim i, ln As Long
- ln = Cells(10000, 1).End(xlUp).Row
- For i = 1 To ln
- Call F2(i)
- Call F3(i)
- Call F4(i)
- Next
- End Sub
- Function F2(ByVal i As Long)
- Dim j, k, l, n
- ReDim arr(100)
- n = 3
- With Sheet1
- For j = 2 To 6
- For l = n To 7
- arr(k) = "'" & .Cells(i, j) & "-" & .Cells(i, l)
- k = k + 1
- Next
- n = n + 1
- Next
- ReDim Preserve arr(k - 1)
- Dim sheetname As String
- sheetname = .Cells(i, 1).Value
- If 工作表是否存在(sheetname) = False Then
- Sheets.Add
- Application.ActiveSheet.Name = .Cells(i, 1)
- End If
- End With
- With Sheets(sheetname)
- .Cells(1, 1) = sheetname
- .Cells(2, 1) = "两两结合"
- .Range(.Cells(2, "c"), .Cells(2, k + 2)) = arr
- End With
- End Function
- Function 工作表是否存在(ByVal sname As String) As Boolean
- Dim i As Integer
- For i = 1 To Sheets.Count
- If Sheets(i).Name = sname Then
- Bs = True
- Exit For
- End If
- Next
- End Function
- Function F3(ByVal i As String)
- Dim j, k, l, n
- ReDim arr(100)
- n = 3
- With Sheet1
- For j = 2 To 5
- For l = n To 7
- If l + 1 <= 7 Then
- arr(k) = "'" & .Cells(i, j) & "-" & .Cells(i, l) & "-" & .Cells(i, l + 1)
- k = k + 1
- End If
- Next
- n = n + 1
- Next
- ReDim Preserve arr(k - 1)
- Dim sheetname As String
- sheetname = .Cells(i, 1).Value
- End With
- With Sheets(sheetname)
- .Cells(3, 1) = "三三结合"
- .Range(.Cells(3, "c"), .Cells(3, k + 2)) = arr
- End With
- End Function
- Function F4(ByVal i As String)
- Dim j, k, l, n
- ReDim arr(100)
- n = 3
- With Sheet1
- For j = 2 To 4
- For l = n To 7
- If l + 2 <= 7 Then
- arr(k) = "'" & .Cells(i, j) & "-" & .Cells(i, l) & "-" & .Cells(i, l + 1) & "-" & .Cells(i, l + 2)
- k = k + 1
- End If
- Next
- n = n + 1
- Next
- ReDim Preserve arr(k - 1)
- Dim sheetname As String
- sheetname = .Cells(i, 1).Value
- End With
- With Sheets(sheetname)
- .Cells(4, 1) = "四四结合"
- .Range(.Cells(4, "c"), .Cells(4, k + 2)) = arr
- End With
- End Function
复制代码
|
|