Format Cell formula vs number

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi, is there a formula for cond. format, if cell is formula / not a formula,
then no formatting / background color. this would occur if typing a number
in place of formula. thanks
 
Add this UDF to a module in your workbook.

Function IsFormula(cell)
IsFormula = cell.HasFormula
End Function

In CF>Formula is: =IsFormula(cellref)


Gord Dibben MS Excel MVP
 
Enter this one-line UDF:

Function isformula(r As Range) As Boolean
isformula = r.HasFormula
End Function

and then for any cell, say A1, pull-down:
Format > Conditional Formatting > Formula is and then
=isformula(a1)
 
hi, thanks; seems I have hardest time with code.
with this example pasted on sheet 2 tab, (right-click, view code, paste..)
did hit save, not sure if necessary; entering a cond. format for background
to go red (for: =isformula(K12)), nothing happens for any present of:
formula, number, empty, text

imagine something simple i am missing
 
on first sheet, am using code:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Target.Row < 56 Then Exit Sub
If Me.Cells(.Row, "A").Value = "." Then Exit Sub
If Not Intersect(Me.Range("BF:BG"), .Cells) Is Nothing Then
Application.EnableEvents = False
With Me.Cells(.Row, "BD")
.NumberFormat = "dd"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub
 
hi, thanks; seems I have hardest time with code.
with this example pasted on SHEET 2 tab, (right-click, view code, paste..)
did hit save, not sure if necessary; entering a cond. format for background
to go red (for: =isformula(K12)), nothing happens for any present of:
formula, number, empty, text

imagine something simple i am missing; On First Sheet, am using code:

Option Explicit
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
With Target
If .Count > 1 Then Exit Sub
If Target.Row < 56 Then Exit Sub
If Me.Cells(.Row, "A").Value = "." Then Exit Sub
If Not Intersect(Me.Range("BF:BG"), .Cells) Is Nothing Then
Application.EnableEvents = False
With Me.Cells(.Row, "BD")
.NumberFormat = "dd"
.Value = Now
End With
Application.EnableEvents = True
End If
End With
End Sub
 
The UDF is to be copied and pasted to a general module in your workbook.

It is a Function, not an event.

Alt + F11 to open VBE then CTRL + r to open Project Explorer.

Right-click on your workbook/project and Insert>Module.


Gord
 
thank you much for help.

Gord Dibben said:
The UDF is to be copied and pasted to a general module in your workbook.

It is a Function, not an event.

Alt + F11 to open VBE then CTRL + r to open Project Explorer.

Right-click on your workbook/project and Insert>Module.


Gord
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top