#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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
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
formating JCRICKET Excel Worksheet Functions 1 April 12th 10 01:44 PM
Formating Tony Excel Discussion (Misc queries) 1 September 14th 07 06:50 PM
Tab formating Brisbane Rob Excel Discussion (Misc queries) 4 January 27th 06 12:21 PM
Install dates formating using conditional formating? Jerry Eggleston Excel Discussion (Misc queries) 2 November 9th 05 05:49 PM
Formating h:mm AM/PM Mike R Excel Discussion (Misc queries) 3 January 7th 05 02:12 AM


All times are GMT +1. The time now is 05:40 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"