Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 22,906
Default 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   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 90
Default 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
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
Quick VBA Worksheet Change Event or Selection Question: Damil4real Excel Worksheet Functions 6 November 17th 09 10:28 PM
change formula in a shared worksheet without losing change history DCE Excel Worksheet Functions 5 July 25th 08 01:37 PM
Hyperlink Question -- Change in Worksheet Name? BG Excel Worksheet Functions 1 March 23rd 08 02:39 PM
Worksheet change Macro Question Vick Excel Discussion (Misc queries) 11 January 30th 08 03:09 PM
VLOOKUP change question roger_home Excel Discussion (Misc queries) 6 February 25th 06 11:06 PM


All times are GMT +1. The time now is 01:15 AM.

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"