Default Values

S

StevenAFC

Is it possible to have a conditional default value, for example, if
enter a value in one cell, it would automatically add another value
But it would allow a person to manually override the value withou
deleting the formula?

For example..

A1 B1
10 < User enters 11.75 < Excel suggest
 
B

Bob Phillips

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "A1:A10" '<=== Change to suit

On Error GoTo ws_exit:
Application.EnableEvents = False
If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
Select Case .Value
Case 10: .Offset(0, 1).Value = 11.75
Case 11: .Offset(0, 1).Value = 11.25
Case 12: .Offset(0, 1).Value = 15
Case 13: .Offset(0, 1).Value = 22
'etc.
End Select
.Offset(0, 1).Select
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)
 
Top