Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formating
I want to enter a number into a cell, divide it by the number of days in the
month, and have the answer appear in that same cell. Is that possible? Thank you for your time. |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formating
No, not using formulas. A cell can contain a formula or a value, but not
both. The alterntive would be to use the worksheet change event. would you want this behavior in only one cell, one column, What? when you say days in month, do you mean the current month? -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... I want to enter a number into a cell, divide it by the number of days in the month, and have the answer appear in that same cell. Is that possible? Thank you for your time. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formating
For instance:
January has 31 days, I want to enter a number, 374 and have it divided by the number of days in January. I need to do that with each month of the year. "Tom Ogilvy" wrote: No, not using formulas. A cell can contain a formula or a value, but not both. The alterntive would be to use the worksheet change event. would you want this behavior in only one cell, one column, What? when you say days in month, do you mean the current month? -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... I want to enter a number into a cell, divide it by the number of days in the month, and have the answer appear in that same cell. Is that possible? Thank you for your time. |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formating
Right click on the sheet tab where you want this behavior
Select view code. Put in code like this Private Sub Worksheet_Change(ByVal Target As Range) On error goto ErrHandler if target.count 1 then exit sub if isempty(target) then exit sub if isnumeric(target) then Application.EnableEvents = False target.Value = Target.Value/Day(DateSerial(year(date),month(date)+1,0)) End if ErrHandler: Application.EnableEvents = True End Sub Alter to meet your specific requirements. -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... For instance: January has 31 days, I want to enter a number, 374 and have it divided by the number of days in January. I need to do that with each month of the year. "Tom Ogilvy" wrote: No, not using formulas. A cell can contain a formula or a value, but not both. The alterntive would be to use the worksheet change event. would you want this behavior in only one cell, one column, What? when you say days in month, do you mean the current month? -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... I want to enter a number into a cell, divide it by the number of days in the month, and have the answer appear in that same cell. Is that possible? Thank you for your time. |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formating
Thanks Tom, I will try that!
"Tom Ogilvy" wrote: Right click on the sheet tab where you want this behavior Select view code. Put in code like this Private Sub Worksheet_Change(ByVal Target As Range) On error goto ErrHandler if target.count 1 then exit sub if isempty(target) then exit sub if isnumeric(target) then Application.EnableEvents = False target.Value = Target.Value/Day(DateSerial(year(date),month(date)+1,0)) End if ErrHandler: Application.EnableEvents = True End Sub Alter to meet your specific requirements. -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... For instance: January has 31 days, I want to enter a number, 374 and have it divided by the number of days in January. I need to do that with each month of the year. "Tom Ogilvy" wrote: No, not using formulas. A cell can contain a formula or a value, but not both. The alterntive would be to use the worksheet change event. would you want this behavior in only one cell, one column, What? when you say days in month, do you mean the current month? -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... I want to enter a number into a cell, divide it by the number of days in the month, and have the answer appear in that same cell. Is that possible? Thank you for your time. |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Formating
Watch word wrap: (I have made these lines shorter)
Private Sub Worksheet_Change(ByVal Target As Range) On error goto ErrHandler if target.count 1 then exit sub if isempty(target) then exit sub if isnumeric(target) then Application.EnableEvents = False target.Value = _ Target.Value/Day(DateSerial( _ year(date),month(date)+1,0)) End if ErrHandler: Application.EnableEvents = True End Sub -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... Thanks Tom, I will try that! "Tom Ogilvy" wrote: Right click on the sheet tab where you want this behavior Select view code. Put in code like this Private Sub Worksheet_Change(ByVal Target As Range) On error goto ErrHandler if target.count 1 then exit sub if isempty(target) then exit sub if isnumeric(target) then Application.EnableEvents = False target.Value = Target.Value/Day(DateSerial(year(date),month(date)+1,0)) End if ErrHandler: Application.EnableEvents = True End Sub Alter to meet your specific requirements. -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... For instance: January has 31 days, I want to enter a number, 374 and have it divided by the number of days in January. I need to do that with each month of the year. "Tom Ogilvy" wrote: No, not using formulas. A cell can contain a formula or a value, but not both. The alterntive would be to use the worksheet change event. would you want this behavior in only one cell, one column, What? when you say days in month, do you mean the current month? -- Regards, Tom Ogilvy "vdefilippo" wrote in message ... I want to enter a number into a cell, divide it by the number of days in the month, and have the answer appear in that same cell. Is that possible? Thank you for your time. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
formating | Excel Worksheet Functions | |||
Formating | Excel Discussion (Misc queries) | |||
Tab formating | Excel Discussion (Misc queries) | |||
Install dates formating using conditional formating? | Excel Discussion (Misc queries) | |||
Formating h:mm AM/PM | Excel Discussion (Misc queries) |