|
Sub zidong()
Dim i, j, k, m, n, irow, s, p, q, t
Dim arr
irow = Sheets("花名册").[a65536].End(xlUp).Row
arr = Sheets("花名册1").Range("a1:m" & irow)
For i = 2 To irow
Sheets("体检表").Cells(13, 5) = arr(i, 3)
Sheets("体检表").Cells(15, 5) = arr(i, 4)
Sheets("体检表").Cells(17, 5) = arr(i, 5)
Sheets("体检表").Cells(19, 5) = arr(i, 11)
Sheets("体检表").Cells(23, 5) = arr(i, 12)
Sheets("体检表").Cells(28, 5) = arr(i, 13)
j = j + 202406220021#
Sheets("体检表").Cells(53, 3) = j
For k = 56 To 57
m = Split(Sheets("体检表").Cells(k, 8), "-")(0)
n = Split(Sheets("体检表").Cells(k, 8), "-")(1)
s = Application.WorksheetFunction.RandBetween(m, n)
Sheets("体检表").Cells(k, 3) = s
Next
For k = 89 To 96
m = Split(Sheets("体检表").Cells(k, 8), "-")(0)
n = Split(Sheets("体检表").Cells(k, 8), "-")(1)
If Val(m) = Int(m) And Val(n) = Int(n) Then
s = Application.WorksheetFunction.RandBetween(m, n)
Sheets("体检表").Cells(k, 3) = s
Else
p = Len(m) - InStr(m, ".")
q = Len(n) - InStr(n, ".")
t = Application.WorksheetFunction.Max(p, q)
s = Application.WorksheetFunction.RandBetween(m * 10 ^ t, n * 10 ^ t)
Sheets("体检表").Cells(k, 3) = s / 10 ^ t
End If
Next
For k = 211 To 255
If Sheets("体检表").Cells(k, 8) <> "" And Sheets("体检表").Cells(k, 9) = "" Then
m = Split(Sheets("体检表").Cells(k, 8), "-")(0)
n = Split(Sheets("体检表").Cells(k, 8), "-")(1)
If Val(m) = Int(m) And Val(n) = Int(n) Then
s = Application.WorksheetFunction.RandBetween(m, n)
Sheets("体检表").Cells(k, 3) = s
Else
p = Len(m) - InStr(m, ".")
q = Len(n) - InStr(n, ".")
t = Application.WorksheetFunction.Max(p, q)
s = Application.WorksheetFunction.RandBetween(m * 10 ^ t, n * 10 ^ t)
Sheets("体检表").Cells(k, 3) = s / 10 ^ t
End If
End If
Next
Sheets("体检表").Copy
ActiveWorkbook.SaveAs ThisWorkbook.Path & "\" & arr(i, 3) & "体检表" & ".xlsx"
ActiveWorkbook.Close True
Next
End Sub |
|