A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » General Discussion
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

worksheet change question



 
 
Thread Tools Display Modes
  #1  
Old April 2nd, 2010, 03:55 PM posted to microsoft.public.excel.misc
Tonso
external usenet poster
 
Posts: 69
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  
Old April 2nd, 2010, 04:14 PM posted to microsoft.public.excel.misc
Gord Dibben
external usenet poster
 
Posts: 20,252
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  
Old April 2nd, 2010, 05:46 PM posted to microsoft.public.excel.misc
Tonso
external usenet poster
 
Posts: 69
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
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 04:55 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.