View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
Gord Dibben Gord Dibben is offline
external usenet poster
 
Posts: 22,906
Default excel formula - possibly visual basic method

David

Without VBA you can have a value or a formula in a cell, not both at the same
time.

I would stick my target number in a cell, say E1

In A1 I would enter the Monday sales figure of 40

In B1 I would enter =A1-E1

Select B1 and FormatConditional FormattingCondition1Formula is =B1<E1
format to red

AddCondition2Formula is =B1=E1 format to green.

These formats can be copied to other cells by using the formatting paintbrush.

If you wnat to do it all in one cell event code is your friend.

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
On Error GoTo enditall
Application.EnableEvents = False
If Target.Cells.Column = 2 Then
n = Target.Row
If Excel.Range("B" & n).Value < "" Then
Excel.Range("B" & n).Value = Excel.Range("B" & n).Value _
- Excel.Range("E1")
End If
End If
enditall:
Application.EnableEvents = True
End Sub

E1 contains your daily target.

Column B is where you enter the daily sales figures.

Also place the CF on column B cells.


Gord Dibben MS Excel MVP


On Thu, 21 Sep 2006 13:04:02 -0700, David
wrote:

I need to set up a quite a complicated spread sheet. This is the senario: say
my sales figure for monday is £50 (which is my target). However my actual
sales figure for monday is £40. How do i get the cell to show the difference
between my forecast(target) and my actual having predefined the cell with my
target sales figure so that when i type the actual sales figure in it will
automatically show the difference(+/-). How do i predefine the cell with the
forecast sales figure for a cell?

In addition to this i would like to know how if i hit the sales target do i
get the cell to show green. And if the sales target is missed how do i get
the cell to show red without having to change the cell each time.

What hopefully should happen is that as in the above scenario if for the
monday i typed in the actual sales figure as £40, the cell will hopefully
show -£10 with the cell baground turning red. If for example i typed in £60
for monday it would show +£10 and the cell would turn green. I hope to repeat
this process for the rest of the week with different forecast figures! Many
thanks