|
第一:数据源在A列,根据E列选择“√”在数据源“%”上复制。结果如G列G13。
第二:E列选择在%以下对应坐标在“M30”之上复制,结果如G44到G46。
第三:重新递增排序如H列(如H13,H44)
最后:把结果放A列。E 列没有“√”,提示没有资料处理。帮忙写个代码,谢谢!!!
- Sub 数据处理()
- 'On Error Resume Next
-
- Dim rgChoose As Range
- Dim rgPer As Range
- Dim rgFin As Range
- Dim str$
- Dim i&
- Dim Address$
-
- Application.ScreenUpdating = False
- Set rgChoose = Range("e:e").Find(what:="√", lookat:=xlWhole)
-
- If rgChoose Is Nothing Then
- MsgBox "没有资料处理"
- Exit Sub
- End If
-
- Set rgPer = Range("a:a").Find(what:="%", lookat:=xlWhole)
- If rgPer Is Nothing Then MsgBox "A列无%": Exit Sub
-
- Cells(rgChoose.Row, 1).Copy
- rgPer.Insert
-
- Application.CutCopyMode = False
-
- str = rgPer.Offset(-1)
- Mid(str, 2, 2) = Val(Mid(rgPer.Offset(-2), 2, 2)) + 1
- rgPer.Offset(-1) = str
-
- str = rgChoose.Offset(, -3)
- str = Left(str, 1) & Right(str, Len(str) - 1) / 1
- Set rgChoose = Nothing
- Set rgChoose = Range("a:a").Find(what:=str, lookat:=xlWhole)
- If rgChoose Is Nothing Then MsgBox "在A列没有找到" & str: Exit Sub
-
- If Range("a:a").Find(what:="M30", lookat:=xlWhole) Is Nothing Then MsgBox "A列无结束标志M30": Exit Sub
-
- i = rgChoose.Row + 1
- Do While Not (Cells(i, 1) Like "T#*" Or Cells(i, 1) Like "M30" Or Len(Cells(i, 1)) = 0)
- i = i + 1
- Loop
- Range(rgChoose, Cells(i - 1, 1)).Copy
-
- Set rgFin = Range("a:a").Find(what:="M30", lookat:=xlWhole)
- Address = rgFin.Address
- rgFin.Insert
-
- Application.CutCopyMode = False
- str = Left(rgPer.Offset(-1).Value, 3)
- Range(Address) = str
- End Sub
复制代码
|
|