#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 1
Default auto divide option

Hi,

when i key in a cell with a number i want that to be divided by 40

Thanks

Fernandez

  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,501
Default auto divide option

Right click the sheet tab, view code and paste this in. Works on the range A1
- A100 so change to suit.

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or Target.HasFormula Or IsEmpty(Target) Then
Exit Sub
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then 'Change to suit
If IsNumeric(Target) Then
Application.EnableEvents = False
Target = Target / 40
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike

"Fernandez" wrote:

Hi,

when i key in a cell with a number i want that to be divided by 40

Thanks

Fernandez

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default auto divide option

Private Sub Worksheet_Change(ByVal Target As Excel.Range)
If Target.Count 1 Then Exit Sub
If Target.Address = "$B$5" Then
If Not IsNumeric(Target.Value) Then Exit Sub
Application.EnableEvents = False
With Target
.Value = .Value / 40
Application.EnableEvents = True

End With
End If
End Sub

Right-click on the sheet tab and "View Code"

Copy/paste the above into that module.

Adjust the $B$5 to suit. You did not give enough information to tailor a
specific cell or range of cells. For the entire sheet, just remove that line
and the End If line.

Alt + q to return to Excel.


Gord Dibben MS Excel MVP

On Tue, 19 Feb 2008 05:02:02 -0800, Fernandez
wrote:

Hi,

when i key in a cell with a number i want that to be divided by 40

Thanks

Fernandez


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
auto correct option aavasilenko Setting up and Configuration of Excel 1 October 18th 07 07:58 PM
Auto fill option Thana New Users to Excel 2 March 9th 06 06:13 PM
Auto-filter option Raj Mazumdar Excel Discussion (Misc queries) 5 January 10th 06 06:11 PM
auto save option Money Minded Setting up and Configuration of Excel 2 June 29th 05 01:01 PM
Divide one row over other row I dont wont to divide one number Rick Excel Discussion (Misc queries) 0 March 4th 05 07:13 PM


All times are GMT +1. The time now is 11:13 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"