Sub A1231213()
ActiveSheet.Copy After:=Sheets(Sheets.Count)
Dim xStr As String
Retry:
Err.Clear
xStr = InputBox("请输入工作表的新名称:" _
, "重命名工作表", ActiveSheet.Name)
If xStr = "" Then Exit Sub
On Error Resume Next
ActiveSheet.Name = xStr
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description
Err.Clear
GoTo Retry
End If
On Error GoTo 0
'.........
Range("K4:K342").Copy
Range("G4:G342").PasteSpecial (xlPasteValues)
Application.CutCopyMode = xlCut
Range("H4:J27,H29:J47,H49:J51,H53:J54,H56:J58,H60:J61,H63:J64,H66:J67,H69:J70,H72:J94,H96:J115,H117:J120,H122:J128,H130:J133,H135:J142,H144:J155,H157:J162,H164:J170,H172:J174,H176:J177,H179:J180,H182:J183,H185:J187,H189:J196,H198:J199,H201:J208,H210:J211,H213:J214,H216:J218,H220:J225,H227:J228,H230:J231,H233:J234,H236:J236,H238:J239,H241:J244,H246:J247,H250:J283,H285:J292,H294:J295,H297:J298,H300:J301,H304:J304,H306:J310,H312:J313,H316:J323,H325:J327,H329:J331,H333:J336,H338:J339").ClearContents
End Sub
宏前面 可以正常运行,到最后一步的选定区域清空就报错 运行错误1004
方法‘range’作用于对象‘_Global’时失败!!! 问题在于 这个宏在WPS中正常运行,在excel就报错!!! 如果录制宏 单独选定多个区域清空,区域一共有339行 清到200行行就停止了!
也试过Union
Dim SuperRange As Range
Set SuperRange = Union(Range("H4:J27,H29:J47"), Range("H49:J51,H53:J54"), Range("H56:J58,H60:J61"), Range("H63:J64,H66:J67"), Range("H69:J70,H72:J94"), Range("H96:J115,H117:J120"), Range("H122:J128,H130:J133"), Range("H135:J142,H144:J155"), Range("H157:J162,H164:J170"))
Set SuperRange = Union(SuperRange, Range("H172:J174,H176:J177"), Range("H179:J180,H182:J183"), Range("H185:J187,H189:J196"), Range("H198:J199,H201:J208"), Range("H210:J211,H213:J214"), Range("H216:J218,H220:J225"), Range("H227:J228,H230:J231"), Range("H233:J234,H236:J236"), Range("H238:J239,H241:J244"), Range("H246:J247,H250:J283"), Range("H285:J292,H294:J295"), Range("H297:J298,H300:J301"), Range("H304:J304,H306:J310"), Range("H312:J313,H316:J323"), Range("H325:J327,H329:J331"), Range("H333:J336,H338:J339"))
SuperRange.selet
selection.ClearContents shift:=xlup
第三行也报错
|