黑帮总裁十八岁vip章节:excel 有用的evba代码

来源:百度文库 编辑:九乡新闻网 时间:2024/04/27 15:05:05
Sub Macro3() '断开到其他 Excel 源的公式
'
' Macro3 Macro
' 宏由 cnmhdzc 录制,时间: 2009-3-22
'
'
Dim astrLinks As Variant
astrLinks = ActiveWorkbook.LinkSources(Type:=xlLinkTypeExcelLinks)
For Each ll In astrLinks
    ActiveWorkbook.BreakLink Name:=ll, Type:=xlLinkTypeExcelLinks
Next ll
End Sub   公式判断 Function IsFormula(ByVal cl As Range) '判断是否公式公式
adrs = cl.Address
If (Len(adrs) > 6) Then     '如果选择多个单元格,认为是非公式
    IsFormula = False
Else
    If (Left(cl.Formula, 1) = "=" And cl.PrefixCharacter <> "'") Then
        IsFormula = True
    Else
        IsFormula = False
    End If
End If
If IsFormula = Null Then IsFormula = False
End Function
Sub Macro2()
'
' Macro2 Macro
' 宏由 cnmhdzc 录制,时间: 2009-3-22
'
'
Dim S As String, L As Integer
For Each dyg In ThisWorkbook.ActiveSheet.UsedRange.Cells               '范围:当前工作薄当前工作表中所有使用中的单元格
    S = dyg.FormulaLocal
    If IsFormula(dyg) And InStr(S, "'!") Then                          '如果单元格是公式且公式包含符号“'!”,
        dyg= "'=" & Right(S, Len(S) - InStr(S, "'!") - 1)     '保留!之后的部分。
    End If
Next dyg
End Sub