|
- Sub 按钮1_Click()
- Set d = CreateObject("scripting.dictionary")
- Set dr = CreateObject("scripting.dictionary")
-
- y = Application.InputBox("请输入生成标题数量:", "输入标题数量", 5, , , , , 1)
- If y = False Then
- MsgBox "请输入有效数字"
- Exit Sub
- End If
- Application.ScreenUpdating = False
-
- arr = [b1:g1]
- For j = 1 To UBound(arr, 2)
- If Len(arr(1, j)) > 0 Then
- dr(arr(1, j)) = ""
- End If
- Next j
- arr = Range([a2], Cells(Rows.Count, 1).End(3))
- For j = 1 To UBound(arr)
- If Not dr.exists(arr(j, 1)) Then
- d(arr(j, 1)) = ""
- End If
- Next j
-
- arr = [b1:g1]
- a = 2
- For i = 1 To y
- l2:
- str1 = ""
- dr.RemoveAll
- For j = 1 To UBound(arr, 2)
- If Len(arr(1, j)) > 0 Then
- dr(arr(1, j)) = ""
- End If
- Next j
- l1:
- If dr.Count > 0 Then
- x = WorksheetFunction.RandBetween(0, 5)
- If x = 1 Then
- x = WorksheetFunction.RandBetween(0, dr.Count - 1)
- str1 = str1 & dr.keys()(x)
- dr.Remove dr.keys()(x)
- Else
- x = WorksheetFunction.RandBetween(0, d.Count - 1)
- str1 = str1 & d.keys()(x)
- End If
- y1 = dr.Count
- If Len(str1) > 60 Then GoTo l2
- GoTo l1:
- End If
- If Len(str1) > 58 Then
- Cells(a, 8) = str1 & Space(60 - Len(str1))
- Cells(a, 9) = Len(Cells(a, 8))
- a = a + 1
- Else
- GoTo l2
- End If
- Next i
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|