Thread: Formating
View Single Post
  #6   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
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.