Cell Formula vs Cell Value

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

Guest

I have a procedure that performs the following. When a user puts a 'Y' in a
certain cell (say B5), then another cell (say A5) is populated with a
formula. When an 'N' is placed in B5, the formula in A5 is removed.
A user is allowed to put his own value in cell A5, but I would like cell B5
to change to N if cell A5 contains a number and not a formula. I have the
following, but need help:

If (tCell.Formula) = "" And tCell.Offset(0, iColumnOffset).Value <> "N" Then
tCell.Offset(0, iColumnOffset).Value = "N"

This only works when the cell A5 is clear. Any suggestions?
 
that is because a number in a cell is considered a formula so to speak

ActiveCell.Value = 5
? activecell.Formula
5

But the HasFormula property only pays attention to a true formula.

? activecell.HasFormula
False

so change to

If Not tCell.HasFormula And tCell.Offset(0, iColumnOffset).Value <> "N"
Then
tCell.Offset(0, iColumnOffset).Value = "N"
 
awesome. Thanks.

Tom Ogilvy said:
that is because a number in a cell is considered a formula so to speak

ActiveCell.Value = 5
? activecell.Formula
5

But the HasFormula property only pays attention to a true formula.

? activecell.HasFormula
False

so change to

If Not tCell.HasFormula And tCell.Offset(0, iColumnOffset).Value <> "N"
Then
tCell.Offset(0, iColumnOffset).Value = "N"
 

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