View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Jock Jock is offline
external usenet poster
 
Posts: 440
Default VBA referencing the result of a formula

Hi Rick,
As a basic scenario, cells in A, B and C are 'summary' cells and have
formulae in them which are date driven and will display "W" in A, "Str" in B
and "Sty" in C when certain conditions are met elsewhere in the sheet.
So when something does appear in any or all of A, B, C in any row, I want
the date that it appeared to be placed on the same row but offset by (0, 44).
This works (using the Worksheet_Change code below) when "W" for instance is
placed in A. However, when "W" appears as the result of a formula, nothing
happens.

code:
On Error GoTo ws_exit:
Application.EnableEvents = False

If Not Intersect(Target, Me.Range("A4:C10000")) Is Nothing Then
With Target
If .Value < "" Then
.Offset(0, 44).Value = Format(Date, "dd/mmm")
End If
End With

End If
How can this be adapted to act when something appears in A:C to place the
date 44 cells along?
Could a simple formula be used in the cells 44 along rather than use code?

--
Traa Dy Liooar

Jock


"Rick Rothstein" wrote:

Always a good idea to post any code you have, that way we would know what it
is you are trying to accomplish with it. It is hard to tell what result you
want to have happen. Here is code for one cell (B1)... you can either expand
on it or come back to the newsgroup and tell us what you actually want to
happen when you find a cell with the letters "ok" in them.

If StrComp(Range("B1").Value, "ok", vbTextCompare) = 0 Then
If Range("B1").HasFormula Then
MsgBox "B1 has a formula and the letters ""OK"" in it."
Else
MsgBox "B1 has ""OK"" in it, but no formula."
End If
End If

--
Rick (MVP - Excel)


"Jock" wrote in message
...
If(A1=Y,ok,"")
Is it possible for code to reference column "B" (where this formula is)
and
detect an 'ok' which has not been manually input?
The code I have works fine when 'ok' is entered but not when it is the
result of a formula.
Thanks
--
Traa Dy Liooar

Jock