如何将下面的excel vba宏更改为仅适用于A55 * B66的第一部分并将B66保留为变量?
Sub Absolute()
'$A$1
Dim cell As Range
For Each cell In Selection
If cell.HasFormula Then
cell.Formula = Application.ConvertFormula(cell.Formula, _
xlA1, xlA1, xlAbsolute)
End If
Next
End Sub
答案 0 :(得分:1)
这是一个有点特别的答案,它适用于两个单元格的乘积公式的特殊情况:
Sub Absolute()
Dim cell As Range
Dim factors As Variant
For Each cell In Selection
If cell.HasFormula And cell.Formula Like "*[*]*" Then
factors = Split(cell.Formula, "*")
factors(0) = Range(factors(0)).Address
cell.Formula = "=" & Join(factors, "*")
End If
Next cell
End Sub