#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 90
Default Excel formulas

I want to enter a value in a cell and have it automatically add a
predetermined value to it. I'm using excell 2003
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default Excel formulas

This is a modification of one of Bernie Deitrick's replies earlier this week

Copy the code below, right-click the sheet tab, select "View Code" and paste
the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers will be entered.
This could be just a single cell as: Set rngPCode = Range("A2")
or a range as in: Set rngPCode = Range("B1:B10")

Also change: MyValue = 3.142 to reflect the value you want to add


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Dim MyValue As Double
MyValue = 3.142
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
Target.Value = Target.Value + MyValue
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"chuck" wrote in message
...
I want to enter a value in a cell and have it automatically add a
predetermined value to it. I'm using excell 2003



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 90
Default Excel formulas

Thanks Bernard your response was very helpful. Now I've got another question.
If I want the the amount added to vary based upon the value that I input, is
that possible?

i.e. less
4 or less add .25
4 to 6 add .50
6 to 9 add .75

"Bernard Liengme" wrote:

This is a modification of one of Bernie Deitrick's replies earlier this week

Copy the code below, right-click the sheet tab, select "View Code" and paste
the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers will be entered.
This could be just a single cell as: Set rngPCode = Range("A2")
or a range as in: Set rngPCode = Range("B1:B10")

Also change: MyValue = 3.142 to reflect the value you want to add


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Dim MyValue As Double
MyValue = 3.142
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
Target.Value = Target.Value + MyValue
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"chuck" wrote in message
...
I want to enter a value in a cell and have it automatically add a
predetermined value to it. I'm using excell 2003




  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 4,393
Default Excel formulas

Try this
Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Dim MyValue As Double
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
MyValue = 0
If Target.Value <= 4 Then
MyValue = 0.25
ElseIf Target.Value < 6 Then
MyValue = 0.5
ElseIf Target.Value < 9 Then
MyValue = 0.75
End If
Target.Value = Target.Value + MyValue
Reset:
Application.EnableEvents = True
End Sub

You should test it. I expect you will be able to modify it as needed
You may need: ElseIf Target.Value <= 6 Then
for less than or equal to 6
best wishes

--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"chuck" wrote in message
...
Thanks Bernard your response was very helpful. Now I've got another
question.
If I want the the amount added to vary based upon the value that I input,
is
that possible?

i.e. less
4 or less add .25
4 to 6 add .50
6 to 9 add .75

"Bernard Liengme" wrote:

This is a modification of one of Bernie Deitrick's replies earlier this
week

Copy the code below, right-click the sheet tab, select "View Code" and
paste
the code into the
window that appears.

Change the
Set rngPCode = Range("D:D")
to the column where the numbers will be entered.
This could be just a single cell as: Set rngPCode = Range("A2")
or a range as in: Set rngPCode = Range("B1:B10")

Also change: MyValue = 3.142 to reflect the value you want to add


Private Sub Worksheet_Change(ByVal Target As Range)
Dim rngPCode As Range
Dim MyValue As Double
MyValue = 3.142
Set rngPCode = Range("D:D")
If Intersect(rngPCode, Target) Is Nothing Then Exit Sub
If Target.Cells.Count 1 Then Exit Sub
On Error GoTo Reset
Application.EnableEvents = False
Target.Value = Target.Value + MyValue
Reset:
Application.EnableEvents = True
End Sub

best wishes
--
Bernard V Liengme
Microsoft Excel MVP
www.stfx.ca/people/bliengme
remove caps from email

"chuck" wrote in message
...
I want to enter a value in a cell and have it automatically add a
predetermined value to it. I'm using excell 2003






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
CELLS NOT CALC FORMULAS - VALUES STAY SME FORMULAS CORRECT?? HELP Sherberg Excel Worksheet Functions 4 September 11th 07 01:34 AM
Copying formulas from Excel 2003 to Excel 2007 [email protected] Excel Discussion (Misc queries) 4 August 9th 07 06:06 PM
Formulas not evaluated, Formulas treated as strings Bob Sullentrup Excel Discussion (Misc queries) 0 November 27th 06 08:01 PM
Excel Formulas Pooja Excel Discussion (Misc queries) 1 March 3rd 06 11:35 PM
excel formulas DL Excel Discussion (Misc queries) 6 January 10th 05 08:45 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"