ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Default Values (https://www.excelbanter.com/excel-discussion-misc-queries/99829-default-values.html)

StevenAFC

Default Values
 

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

For example..

A1 B1
10 < User enters 11.75 < Excel suggests


--
StevenAFC
------------------------------------------------------------------------
StevenAFC's Profile: http://www.excelforum.com/member.php...o&userid=36471
View this thread: http://www.excelforum.com/showthread...hreadid=562365


Bob Phillips

Default Values
 
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)

"StevenAFC" wrote
in message ...

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

For example..

A1 B1
10 < User enters 11.75 < Excel suggests


--
StevenAFC
------------------------------------------------------------------------
StevenAFC's Profile:

http://www.excelforum.com/member.php...o&userid=36471
View this thread: http://www.excelforum.com/showthread...hreadid=562365




StevenAFC

Default Values
 

Thanks for the reply, i thought i might have to go down the VBA/Macro
route.


--
StevenAFC
------------------------------------------------------------------------
StevenAFC's Profile: http://www.excelforum.com/member.php...o&userid=36471
View this thread: http://www.excelforum.com/showthread...hreadid=562365



All times are GMT +1. The time now is 07:13 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com