ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Worksheet Functions (https://www.excelbanter.com/excel-worksheet-functions/)
-   -   Entering numbers in a cel formula (https://www.excelbanter.com/excel-worksheet-functions/87436-entering-numbers-cel-formula.html)

argonaut

Entering numbers in a cel formula
 
This is probably a question that has been brought up before, but I am trying
to set up a cel that will contain a formula, BUT, that I can also enter a
number in the cel and it will preform a caculation based on the formula. In
other words, I want to set up D1 to be =D1+1.5, and when I enter 5 into D1,
then 6.5 is what shows. Is this something I can do with a macro or vba? Any
help is appreciated.

Gary''s Student

Entering numbers in a cel formula
 
Enter this small macro in worksheet code:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("D1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Value = Target.Value + 1.5
Application.EnableEvents = True
End Sub


Remember: worksheet code, not a module.
--
Gary's Student


"argonaut" wrote:

This is probably a question that has been brought up before, but I am trying
to set up a cel that will contain a formula, BUT, that I can also enter a
number in the cel and it will preform a caculation based on the formula. In
other words, I want to set up D1 to be =D1+1.5, and when I enter 5 into D1,
then 6.5 is what shows. Is this something I can do with a macro or vba? Any
help is appreciated.


argonaut

Entering numbers in a cel formula
 

Is there a way to do it for an entire column, or multiple rows? I tried to
do it as a macro and for some reason it is not working properly.


"Gary''s Student" wrote:

Enter this small macro in worksheet code:

Sub Worksheet_Change(ByVal Target As Excel.Range)
If Intersect(Range("D1"), Target) Is Nothing Then Exit Sub
Application.EnableEvents = False
Target.Value = Target.Value + 1.5
Application.EnableEvents = True
End Sub


Remember: worksheet code, not a module.
--
Gary's Student


"argonaut" wrote:

This is probably a question that has been brought up before, but I am trying
to set up a cel that will contain a formula, BUT, that I can also enter a
number in the cel and it will preform a caculation based on the formula. In
other words, I want to set up D1 to be =D1+1.5, and when I enter 5 into D1,
then 6.5 is what shows. Is this something I can do with a macro or vba? Any
help is appreciated.



All times are GMT +1. The time now is 03:16 AM.

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