ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Formating (https://www.excelbanter.com/excel-programming/328743-formating.html)

vdefilippo

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.



Tom Ogilvy

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.





vdefilippo

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.






Tom Ogilvy

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.








vdefilippo

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.









Tom Ogilvy

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.












All times are GMT +1. The time now is 01:00 PM.

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