Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Altering cell contents
Hi,
What I am trying to achieve is to be able to alter the contents of a particular cell. If I type 2300 into the cell I want the cell to automatically update with 23:00 The code I have so far is: Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range) Dim TargetRow As String Dim TargetColumn As String Dim IntValue As String Dim TargetHours As String Dim TargetMins As String TargetRow = Target.Row TargetColumn = Target.Column IntValue = Format(Target.Worksheet.Cells(Target.Row, Target.Column).Value, "0000") TargetHours = Left(IntValue, 2) TargetMins = Right(IntValue, 2) Target.Worksheet.Cells(Target.Row, Target.Column) = TargetHours & ":" & TargetMins End Sub the trouble is that the cell gets updated with 00:00 all the time. When I try to format the cell (after it has been formatted) it is always on a custom format of hh:mm which is OK but I am thinking the formatting may be at fault somewhere?? I am using office 2000. Any help is appreciated. --- Message posted from http://www.ExcelForum.com/ |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
concatenate contents of cells whose contents resemble cell referem | Excel Worksheet Functions | |||
Prevent cell/array references from changing when altering/moving thecell/array | Excel Discussion (Misc queries) | |||
Macro to remove contents of cell and move all other contents up one row | Excel Discussion (Misc queries) | |||
Cell contents vs. Formula contents | Excel Discussion (Misc queries) | |||
Altering UI Programatically | Excel Programming |