...那能不能只锁行 或则列呢?相对的代码是什么样啊?
发布网友
发布时间:2024-09-07 09:10
我来回答
共3个回答
热心网友
时间:2024-11-12 14:16
在EXCEL HOME见到过一个最全的转换代码
Option Explicit
Sub g() '将相对引用转为绝对引用
Dim c As Range
For Each c In Cells.SpecialCells(xlCellTypeFormulas, 23)
c.Formula = Application.ConvertFormula(c.Formula, xlA1, xlA1, xlRelRowAbsColumn)
Next
End Sub
Sub gg() '将相对引用转为行绝对列相对引用
Dim c As Range
For Each c In Cells.SpecialCells(xlCellTypeFormulas, 23)
c.Formula = Application.ConvertFormula(c.Formula, xlA1, xlA1, xlAbsRowRelColumn)
Next
End Sub
Sub ggg() '将相对引用转为行相对列绝对引用
Dim c As Range
For Each c In Cells.SpecialCells(xlCellTypeFormulas, 23)
c.Formula = Application.ConvertFormula(c.Formula, xlA1, xlA1, xlAbsolute)
Next
End Sub
Sub gggg() '将绝对引用转为相对引用
Dim c As Range
For Each c In Cells.SpecialCells(xlCellTypeFormulas, 23)
c.Formula = Application.ConvertFormula(c.Formula, xlA1, xlA1, xlRelative)
Next
End Sub
Sub RC_A1() 'R1C1格式转换
With Application
If .ReferenceStyle = xlR1C1 Then
.ReferenceStyle = xlA1
Else
.ReferenceStyle = xlR1C1
End If
End With
End Sub
热心网友
时间:2024-11-12 14:12
sheet1中A1=34,A2=32,A3=33,即单元格里面是数值,那么sheet2中直接公式A1=Sheet1!A1,不需要什么绝对引用即可复制公式。
sheet2中的公式向其他sheet粘贴时,如果需要绝对引用,把sheet2中的公式锁定后粘贴即可。
热心网友
时间:2024-11-12 14:11
这个意思?
Sub AA()
Dim i, K
For i = 1 To 5 '1 到 5行
For K = 1 To 3 'A:C列
Cells(i, K).SpecialCells (xlCellTypeFormulas)
Cells(i, K) = Application.ConvertFormula(Cells(i, K).Formula, xlA1, , xlAbsolute)
Next
Next
End Sub
Sub BB()
Dim i, K
For i = 1 To 5 '1 到 5行
For K = 1 To 3 'A:C列
Cells(i, K).SpecialCells (xlCellTypeFormulas)
Cells(i, K) = Application.ConvertFormula(Cells(i, K).Formula, xlA1, , xlRelative, Cells(i, K))
Next
Next
End Sub