Home |
Search |
Today's Posts |
|
#1
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
change scaling % but font size didnt change porportionally, pls he | Excel Discussion (Misc queries) | |||
Excel bar chart formatting of bars to change colors as data change | Excel Discussion (Misc queries) | |||
Use date modified to change format & create filter to track change | Excel Worksheet Functions | |||
change info in other cells when i change a number in a drop list? | Excel Discussion (Misc queries) | |||
Change workbook sheet reference using cell A1 to change a vairable | Excel Worksheet Functions |