Hello:
Just wondering how to go about having my cells automatically change 0800 into 08:00 so that I don't have input the : everytime.
Thanks for the help!
12 1307
Hello:
Just wondering how to go about having my cells automatically change 0800 into 08:00 so that I don't have input the : everytime.
Thanks for the help!
What language are you implementing in?
What types of objects are your "cells"?
please be specific..
i don't know what type of cells you are talking about...
Excel ??
In Excel 2003:
Right click the cell or range of cells, choose Format Cells. On the first tab in the dialog box that appears, choose Custom (bottom of list). Click on one of the formats, and then enter this: 00":"00 in the Type text box.
Regards,
Scott
Nice, Scott. Much more better than the event handler I've almost posted. LOL.
Okay that was simple and does the trick.
I coudl fall in love with ya'll over all this hehe
Glad it works for you!
The simpler the better IMHO :-)
Regards,
Scott
Nice, Scott. Much more better than the event handler I've almost posted. LOL.
Thanks, Fish!
Would be interesting to see the event handler, though... It could probably have a few added features that make it more powerful?
Regards,
Scott
Something like this. -
Private Sub Worksheet_Change(ByVal Target As Range)
-
-
Static blnIsExecuted As Boolean
-
-
If blnIsExecuted Then Exit Sub
-
-
With Target
-
'Somewhat speculative cell format check, should be smthng else
-
If InStr(1, .NumberFormat, "h:mm") > 2 Or _
-
InStr(1, .NumberFormat, "h:mm") < 1 Then Exit Sub
-
blnIsExecuted = True
-
.Value = Int(.Value / 100) & ":" & Format(.Value Mod 100, "00")
-
blnIsExecuted = False
-
End With
-
-
End Sub
-
Something like this. -
Private Sub Worksheet_Change(ByVal Target As Range)
-
-
Static blnIsExecuted As Boolean
-
-
If blnIsExecuted Then Exit Sub
-
-
With Target
-
'Somewhat speculative cell format check, should be smthng else
-
If InStr(1, .NumberFormat, "h:mm") > 2 Or _
-
InStr(1, .NumberFormat, "h:mm") < 1 Then Exit Sub
-
blnIsExecuted = True
-
.Value = Int(.Value / 100) & ":" & Format(.Value Mod 100, "00")
-
blnIsExecuted = False
-
End With
-
-
End Sub
-
I didn't even know Excel had event handlers :P
I'm going to have to take a look at it more!
NeoPa 32,556
Expert Mod 16PB
I typically use a global flag to indicate that the code is already running, as other routines also need to know, but the static internal one also works well in this specific case. - 'This routine ensures the figure is only updated when appropriate
-
'It relies on a variable (blnBlock) defined (as Public) in a standard code
-
'module within the project. You can add other criteria if required.
-
Private Sub Workbook_SheetChange(ByVal Sh As Object, ByVal Target As Range)
-
With Target
-
If blnBlock _
-
Or InStr(1, .Address, ":") > 0 _
-
Or InStr(1, .Address, ",") > 0 _
-
Or InStr(1, .Value, ":") > 0 Then Exit Sub
-
blnBlock = True
-
.Value = Format(.Value, "00:00")
-
'If a text result is explicitly required use the following line instead
-
'.Value = Format(.Value, "'00:00")
-
blnBlock = False
-
End With
-
End Sub
NeoPa 32,556
Expert Mod 16PB
I didn't even know Excel had event handlers :P
I'm going to have to take a look at it more!
If you look in the VBA window (Alt-F11) you will see a couple of drop-downs in the Code Pane (F7). The one on the left allows you to select an object and then the one on the right lists the possible events to handle. If you select one it will even create a skeleton routine for you (empty of course).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: svilen |
last post by:
hello again.
i'm now into using python instead of another language(s) for
describing structures of data, including names, structure,
type-checks, conversions, value-validations, metadata etc....
|
by: Mel |
last post by:
when downloading files from my site, when file types are known (i.e *.doc)
browsers open the file for viewing.
is there a way to disable that and just present the save as dialog (same as
for...
|
by: Dymov Vlad |
last post by:
Hello, All!
I have some trouble with subject.
Maybe it is not trouble at all, but i need a good advise.
I have just tried to write simple ASPX page in HTML view.
Everything was good....
|
by: Matt |
last post by:
I have begun designing and programming in C++ after a several years
away from software engineering/programming.
I am looking for an "automatic C++ header generator." I have what
seems to be...
|
by: pjac |
last post by:
I need assistance in creating an Automatic tracking number that
appears in a textbox that looks like: 2004-001. The first part of the
number is based on the year, the second part is generated from...
|
by: m_houllier |
last post by:
STUDENT TABLE
StudentReference
Student Name
etc
ATTENDANCE TABLE
AttendanceID
CourseID
StudentReference
|
by: Michel Esber |
last post by:
Hello,
Linux RedHat AS4 running DB2 V8 FP11.
I have followed the docs at http://tinyurl.com/qckrn and enabled
automatic statistics collection. It has been 2 days since I updated my
DB cfg and...
|
by: Russell Mangel |
last post by:
I am using VS2005.
When I paste source code into the code window, VS2005 formats like the
following:
public MsgRecipientReader()
: base()
{
}
|
by: Jorge Peixoto de Morais Neto |
last post by:
I was reading the code of FFmpeg and it seems that they use malloc
just too much. The problems and dangers of malloc are widely known.
Malloc also has some overhead (although I don't know what is...
|
by: bryars |
last post by:
I want to write some SQL which results in an automatic conversion of a
datetime to a string in a format suitable for the Language of the
connection (either by explicitly setting the Language in the...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |