我尝试创建一个宏,该宏可以在列中找到最大数值(也包含文本),并插入一个值为+1的新行。
出于某种原因,它不会起作用而只保留原始数字,它也会扰乱我在D列中的条件格式,即使该列被锁定。
Sub_Move()
Set wk1 = Sheet1
Set wk2 = Sheet4
Set wk3 = Sheet5
Dim mynumber As Long
Application.ScreenUpdating = False
Sheet1.Unprotect
Sheet4.Unprotect
Sheet5.Unprotect
mynumber = 1
'Move-Characterisation'
Worksheets("Characterisation").Activate
For i = 1000 To 15 Step -1
If Range("W" & i).Value = "Completed" Then
Worksheets("Burn").Activate
Range("B15:W15").Select
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("B15:W15").Interior.ColorIndex = xlNone
End If
Worksheets("Characterisation").Activate
If Range("W" & i).Value = "Completed" Then
Range("W" & i).Select
Range("W" & i).Value = "Delete"
Range(ActiveCell, ActiveCell.Offset(0, -21)).Select
Selection.Copy
Worksheets("Burn").Activate
Range("B15").Select
ActiveSheet.Paste
Range("W15").ClearContents
**MaxVal1 = Application.WorksheetFunction.Max(wk2.Range("D15:D1000"))
Range("D15").Value = MaxVal1 + 1**
End If
Worksheets("Characterisation").Activate
If Range("W" & i).Value = "Delete" Then
Range("W" & i).Select
Range(ActiveCell, ActiveCell.Offset(0, -21)).Select
Selection.Delete Shift:=xlUp
End If
Next
如果有任何帮助,我将不胜感激。