- Sub tq()
- Dim pat, ir%, il%, n%, arr
- Application.DisplayAlerts = Fasle '表示禁止显示提示和警告消息
- pat = ThisWorkbook.Path
- Workbooks.Open pat & "/800.txt"
- ir = Range("a65536").End(xlUp).Row
- il = Cells(1, Cells.Columns.Count).End(xlToLeft).Column
- n = Int(Rnd() * (ir - 4)) + 1
- arr = Range(Cells(n, il), Cells(n + 4, il)).Value
- ActiveWorkbook.Close
- Range("a2").Resize(4, UBound(arr, 2)) = arr
- Range("A2:A5").Select
- Selection.TextToColumns Destination:=Range("A2"), DataType:=xlFixedWidth, _
- FieldInfo:=Array(Array(12, 1), Array(13, 1), Array(14, 1), Array(15, 1), Array(16, 1)) _
- , TrailingMinusNumbers:=True
- Application.DisplayAlerts = True '表示显示提示和警告消息
- End Sub
复制代码 |