Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.misc
|
|||
|
|||
worksheet change question
I want to be able to enter a time, using "." instead of ":", so that
when I enter the number, then press "Enter", the number changes from, say, 13.27.33 to 13:27:33. But I am having to reselect the cell to get it to change. What is wrong with my code? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Selection.Replace What:=".", Replacement:=":", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.NumberFormat = "h:mm:ss" End Sub Thanks, Tonso |
#2
Posted to microsoft.public.excel.misc
|
|||
|
|||
worksheet change question
Wrong event. Try this one.
Private Sub Worksheet_Change(ByVal Target As Range) Target.Replace What:=".", Replacement:=":", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Target.NumberFormat = "h:mm:ss" End Sub Gord Dibben MS Excel MVP On Fri, 2 Apr 2010 07:55:51 -0700 (PDT), Tonso wrote: I want to be able to enter a time, using "." instead of ":", so that when I enter the number, then press "Enter", the number changes from, say, 13.27.33 to 13:27:33. But I am having to reselect the cell to get it to change. What is wrong with my code? Private Sub Worksheet_SelectionChange(ByVal Target As Range) Selection.Replace What:=".", Replacement:=":", LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False Selection.NumberFormat = "h:mm:ss" End Sub Thanks, Tonso |
#3
Posted to microsoft.public.excel.misc
|
|||
|
|||
worksheet change question
On Apr 2, 11:14*am, Gord Dibben <gorddibbATshawDOTca wrote:
Wrong event. *Try this one. Private Sub Worksheet_Change(ByVal Target As Range) * * Target.Replace What:=".", Replacement:=":", LookAt:=xlPart, _ * * * * SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ * * * * ReplaceFormat:=False * * Target.NumberFormat = "h:mm:ss" End Sub Gord Dibben *MS Excel MVP On Fri, 2 Apr 2010 07:55:51 -0700 (PDT), Tonso wrote: I want to be able to enter a time, using "." instead of ":", so that when I enter the number, then press "Enter", the number changes from, say, 13.27.33 to 13:27:33. But I am having to reselect the cell to get it to change. What is wrong with my code? Private Sub Worksheet_SelectionChange(ByVal Target As Range) * *Selection.Replace What:=".", Replacement:=":", LookAt:=xlPart, _ * * * *SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ * * * *ReplaceFormat:=False * *Selection.NumberFormat = "h:mm:ss" End Sub Thanks, Tonso- Hide quoted text - - Show quoted text - As always Gord, thanks so much. it works perfectlty!!! Tonso |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Quick VBA Worksheet Change Event or Selection Question: | Excel Worksheet Functions | |||
change formula in a shared worksheet without losing change history | Excel Worksheet Functions | |||
Hyperlink Question -- Change in Worksheet Name? | Excel Worksheet Functions | |||
Worksheet change Macro Question | Excel Discussion (Misc queries) | |||
VLOOKUP change question | Excel Discussion (Misc queries) |