Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 127
Default Change :47:57 to 0:47:57

Hi Experts:

I have a Macro that will pop time to a worksheet...the problem is I can't
determine how to make it pop with a left Zero fill if there are no hours.
Example: :47:57 change to 0:47:57 whe the Macro pops instead of the :47:57.

Can anyone tell me how to do this?

Thanks for your assistance,
--
jeannie v
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 10,593
Default Change :47:57 to 0:47:57

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Left(.Value, 1) = ":" Then
.Value = "0" & .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"jeannie v" wrote in message
...
Hi Experts:

I have a Macro that will pop time to a worksheet...the problem is I can't
determine how to make it pop with a left Zero fill if there are no hours.
Example: :47:57 change to 0:47:57 whe the Macro pops instead of the
:47:57.

Can anyone tell me how to do this?

Thanks for your assistance,
--
jeannie v



  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 127
Default Change :47:57 to 0:47:57

Good Morning, Bob:

Excellent! It worked perfectly!!!! Thank you for lending your expertise!
--
jeannie v


"Bob Phillips" wrote:

Private Sub Worksheet_Change(ByVal Target As Range)
Const WS_RANGE As String = "H1:H10" '<== change to suit

On Error GoTo ws_exit
Application.EnableEvents = False

If Not Intersect(Target, Me.Range(WS_RANGE)) Is Nothing Then
With Target
If Left(.Value, 1) = ":" Then
.Value = "0" & .Value
End If
End With
End If

ws_exit:
Application.EnableEvents = True
End Sub

'This is worksheet event code, which means that it needs to be
'placed in the appropriate worksheet code module, not a standard
'code module. To do this, right-click on the sheet tab, select
'the View Code option from the menu, and paste the code in.



--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"jeannie v" wrote in message
...
Hi Experts:

I have a Macro that will pop time to a worksheet...the problem is I can't
determine how to make it pop with a left Zero fill if there are no hours.
Example: :47:57 change to 0:47:57 whe the Macro pops instead of the
:47:57.

Can anyone tell me how to do this?

Thanks for your assistance,
--
jeannie v




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
change scaling % but font size didnt change porportionally, pls he Scaling question Excel Discussion (Misc queries) 0 March 12th 07 03:16 AM
Excel bar chart formatting of bars to change colors as data change JudyT Excel Discussion (Misc queries) 1 January 24th 07 06:07 PM
Use date modified to change format & create filter to track change PAR Excel Worksheet Functions 0 November 15th 06 09:17 PM
change info in other cells when i change a number in a drop list? macbr549 Excel Discussion (Misc queries) 2 September 11th 05 02:07 AM
Change workbook sheet reference using cell A1 to change a vairable Reed Excel Worksheet Functions 4 January 20th 05 07:15 PM


All times are GMT +1. The time now is 11:40 PM.

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"