|
左边表格C20根据右边I列变化而变化I列一个数字对应生成左边一个表格如果I列有20个数字就生成20页左边一样的表F26设定为随机的<15-28Ω之间,或者以这个代码帮我改一下感谢大家。Sub 分表() Dim iRow As Integer, i As Integer, strName As String, sht As Worksheet
iRow = Range("i" & Rows.Count).End(xlUp).Row
For i = 20 To iRow
If Worksheets("16").Range("I" & i).Value = "" Then
i = i + 1
End If
strName = Worksheets("16").Range("i" & i).Value
On Error Resume Next
Set sht = Worksheets(strName)
If Err.Number <> 0 Then
Set sht = Worksheets.Add(after:=Worksheets(Worksheets.Count))
sht.Name = strName
End If
Worksheets("16").Range("a1").Resize(Rows.Count, 7).Copy _
sht.Range("a1").Resize(Rows.Count, 7)
sht.Range("c20").Value = sht.Name
Next i
Worksheets("16").Select
|
|
|
|