View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Executor Executor is offline
external usenet poster
 
Posts: 74
Default VBA to "Label" and "Unlabel" formula

Hi brandtboo0,

If it is not a problem using a # in front of formules and fugures:

Public Sub ToggleFunction()
Dim strContents As String
If Not IsEmpty(ActiveCell) Then
If ActiveCell.HasFormula Then
ActiveCell.Value = "#" & ActiveCell.Formula
Else
If Not IsNumeric(ActiveCell) Then
strContents = ActiveCell.Text
If Left(strContents, 2) = "#=" Then
ActiveCell.Formula = Mid(strContents, 2)
Else
ActiveCell.Value = Mid(strContents, 2)
End If
Else
ActiveCell.Value = "#" & ActiveCell.Text
End If
End If
End If
End Sub

HTH


Executor.