Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Document Specific Autocorrection

I'm trying to create an excel spreadsheet that allows the user to input a
number of hours worked for any given date, but for the spreadsheet to add
only the previous 28 day's worth of hours. Everything is going fine, except I
want to be able to input 1 hour 35 minutes as 1.35 and not 1:35. I found
autocorrection could automatically change the "." to a ":" so it's still
understood as a time by excel. However, adding this to autocorrection changes
my default settings across the program. Is there a way to make this file
specific, so that it affects only this file, and so that it will carry over
if another user opens the file on their computer.

Equally, if autocorrection cannot do this, is there a cell specific formula
to do this, or any other way to input the time using a full stop instead of a
colon?

Thanks,

Chris
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 11,501
Default Document Specific Autocorrection

Hi,

Autocorrect is global so that solution would change all . to : in Word which
would be a bit of a pain. Try this instead. Right click your sheet tab, view
code and paste this in on the right. It's cirrently set to work on A1:a100

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target.Value = WorksheetFunction.Substitute(Target.Value, ".", ":")
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike

"TheBroon" wrote:

I'm trying to create an excel spreadsheet that allows the user to input a
number of hours worked for any given date, but for the spreadsheet to add
only the previous 28 day's worth of hours. Everything is going fine, except I
want to be able to input 1 hour 35 minutes as 1.35 and not 1:35. I found
autocorrection could automatically change the "." to a ":" so it's still
understood as a time by excel. However, adding this to autocorrection changes
my default settings across the program. Is there a way to make this file
specific, so that it affects only this file, and so that it will carry over
if another user opens the file on their computer.

Equally, if autocorrection cannot do this, is there a cell specific formula
to do this, or any other way to input the time using a full stop instead of a
colon?

Thanks,

Chris

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Document Specific Autocorrection

Just the job - thanks Mike!

"Mike H" wrote:

Hi,

Autocorrect is global so that solution would change all . to : in Word which
would be a bit of a pain. Try this instead. Right click your sheet tab, view
code and paste this in on the right. It's cirrently set to work on A1:a100

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target.Value = WorksheetFunction.Substitute(Target.Value, ".", ":")
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike

"TheBroon" wrote:

I'm trying to create an excel spreadsheet that allows the user to input a
number of hours worked for any given date, but for the spreadsheet to add
only the previous 28 day's worth of hours. Everything is going fine, except I
want to be able to input 1 hour 35 minutes as 1.35 and not 1:35. I found
autocorrection could automatically change the "." to a ":" so it's still
understood as a time by excel. However, adding this to autocorrection changes
my default settings across the program. Is there a way to make this file
specific, so that it affects only this file, and so that it will carry over
if another user opens the file on their computer.

Equally, if autocorrection cannot do this, is there a cell specific formula
to do this, or any other way to input the time using a full stop instead of a
colon?

Thanks,

Chris

  #4   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 3
Default Document Specific Autocorrection

Actually, it turns out that didn't quite do it...had a few flaws, like "1.00"
became ":10" instead of "1:00". and "1.10" became "1:01" instead of "1:10"!

Talking to a friend, he finally sorted it out. So for anyone else trying the
same thing, the code he put together was:

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("E1:E100")) Is Nothing Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False

Dim str As String
Dim lft As String
Dim regs As String
Dim pos As Integer
Dim res As String

str = WorksheetFunction.Substitute(Target.Value, ".", ":")
pos = InStr(1, str, ":", vbTextCompare)

If (pos 0) Then
lft = Left(str, pos - 1)
regs = Right(str, Len(str) - pos)
If Len(regs) = 1 Then regs = regs + "0"
res = lft + ":" + regs
Else
res = str + ":00"
End If

Target.Value = res


Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub





"TheBroon" wrote:

Just the job - thanks Mike!

"Mike H" wrote:

Hi,

Autocorrect is global so that solution would change all . to : in Word which
would be a bit of a pain. Try this instead. Right click your sheet tab, view
code and paste this in on the right. It's cirrently set to work on A1:a100

Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Cells.Count 1 Or IsEmpty(Target) Then Exit Sub
If Not Intersect(Target, Range("A1:A100")) Is Nothing Then
If IsNumeric(Target) Then
On Error Resume Next
Application.EnableEvents = False
Target.Value = WorksheetFunction.Substitute(Target.Value, ".", ":")
Application.EnableEvents = True
On Error GoTo 0
End If
End If
End Sub

Mike

"TheBroon" wrote:

I'm trying to create an excel spreadsheet that allows the user to input a
number of hours worked for any given date, but for the spreadsheet to add
only the previous 28 day's worth of hours. Everything is going fine, except I
want to be able to input 1 hour 35 minutes as 1.35 and not 1:35. I found
autocorrection could automatically change the "." to a ":" so it's still
understood as a time by excel. However, adding this to autocorrection changes
my default settings across the program. Is there a way to make this file
specific, so that it affects only this file, and so that it will carry over
if another user opens the file on their computer.

Equally, if autocorrection cannot do this, is there a cell specific formula
to do this, or any other way to input the time using a full stop instead of a
colon?

Thanks,

Chris

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
Macro to open specific document Thew21 Excel Discussion (Misc queries) 1 December 13th 06 01:18 PM
How to hyperlink to a specific location in a Word document? DEVAR Excel Discussion (Misc queries) 6 August 4th 06 06:46 PM
shortcuts ("abbreviations", autocorrection) with non-wordbreaking characters Johannes Zellner Excel Discussion (Misc queries) 0 July 19th 06 09:30 AM
getting specific info from a word document into excel smintey Excel Discussion (Misc queries) 3 December 8th 04 08:20 PM
Getting specific data from a word document into an excel sheet smintey Excel Worksheet Functions 3 December 7th 04 05:17 PM


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