|
- Sub 复制()
- Dim nRept As Long '复制次数
- Dim nSpace As Long '间隔数(几种花)
- Dim nBlank As Long '空白数
- Dim arr, n As Long, m As Long
- Dim trr(1 To 1, 1 To 1)
- Dim brr(), b As Long
- Dim i As Long, j As Long, k As Long
-
- nRept = Val(ActiveSheet.Shapes("TextBox 4").TextFrame2.TextRange.Text)
- nSpace = Val(ActiveSheet.Shapes("TextBox 5").TextFrame2.TextRange.Text)
- If nSpace = 0 Then nSpace = 1
- nBlank = Val(ActiveSheet.Shapes("TextBox 3").TextFrame2.TextRange.Text)
-
- Rem 判断复制次数是否为0
- If nRept = 0 Then
- MsgBox "请填写复制次数!"
- Exit Sub
- End If
-
- Rem 数据存数组
- n = Range("A" & Rows.Count).End(xlUp).Row
- If n = 1 Then
- trr(1, 1) = Range("A1").Value
- arr = trr
- Else
- arr = Range("A1").Resize(n, 1).Value
- End If
-
- Rem 计算
- ReDim brr(1 To n * nRept + ((n \ nSpace) + 1) * nBlank)
- For i = 1 To n
- For j = i To IIf(i + nSpace - 1 > n, n, i + nSpace - 1)
- Rem 重复
- For k = 1 To nRept
- b = b + 1
- brr(b) = arr(j, 1)
- Next
- Next
-
- Rem 空白
- b = b + 4
-
- i = i + nSpace - 1
- Next
-
- Columns("B").ClearContents '清除原内容
-
- Rem 输入结果
- Range("B1").Resize(UBound(brr), 1) = Application.WorksheetFunction.Transpose(brr)
-
- MsgBox "处理完成!"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|