我在 H 列中有这个列表。
这是我的宏excel代码
Sub TheSpaceBetween1()
Dim ws As Worksheet
Dim LRow As Long, i As Long
Dim insertRange As Range
'~~> Chnage this to the relevant sheet
Set ws = ActiveSheet
'~~> Work with the relevant sheet
With ws
'~~> Get the last row of the desired column
LRow = .Range("H" & .Rows.Count).End(xlUp).Row
'~~> Loop from last row up
For i = LRow To 1 Step -1
'~~> Check for the condition
'~~> UCASE changes to Upper case
'~~> TRIM removes unwanted space from before and after
If UCase(Trim(.Range("H" & i).Value)) = "NOT THE SAME" Then
'~~> Insert the rows
Selection.FormulaArray = "=MIN(IF(C[-7]=RC[-7],C[-6]))" <----this is the problem
End If
Next i
End With
End Sub
不幸的是,它不起作用。假设用这个公式替换单词 NOT THE SAME
Selection.FormulaArray = "=MIN(IF(C[-7]=RC[-7],C[-6]))"
宏的作用是
将所有单元格内容替换为与公式不一样的文本Selection.FormulaArray = "=MIN(IF(C[-7]=RC[-7],C[-6]))"
有人可以帮助我使代码正常工作吗?