Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27
Default an earlier post

Hello Everyone,

(this is a repost, the first time I sent it in€¦it didnt post??)
I have a question about an earlier post in the worksheet functions group
from 12/09/04. There was a question about converting numbers to time without
putting in the colons. The answer was a referral to Chip Pearsons site. He
posted some code that converts any 4 numbers to time ie. 1234 to 12:34.
I want to know if it will work if I name a range due to the fact that my
cells are kind of scattered over the sheet and there are a lot of them. For
example this:

A5:A14,B5:B14,E5:E14,F5:F14 (many more than this)

I also want to know how I can make it work for the 6 digit format ie. 123456
to 12:34:56. Thanks for your help.

Rob

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default an earlier post

Don't know about Chip's code, but this works on a named range

Sub ChangeTime()
Dim cell As Range
Dim nHours As Long
Dim nMinutes As Long
Dim nSeconds As Long

For Each cell In Range("rng")
If IsNumeric(cell.Value) And cell.Value < "" Then
With cell
nHours = .Value \ 10000
nMinutes = (.Value - nHours * 10000) \ 100
nSeconds = .Value Mod 100
.Value = TimeSerial(nHours, nMinutes, nSeconds)
End With
End If
Next cell

End Sub


--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Robb27" wrote in message
...
Hello Everyone,

(this is a repost, the first time I sent it in.it didn't post??)
I have a question about an earlier post in the worksheet functions group
from 12/09/04. There was a question about converting numbers to time

without
putting in the colons. The answer was a referral to Chip Pearson's site.

He
posted some code that converts any 4 numbers to time ie. 1234 to 12:34.
I want to know if it will work if I name a range due to the fact that my
cells are kind of scattered over the sheet and there are a lot of them.

For
example this:

A5:A14,B5:B14,E5:E14,F5:F14 (many more than this)

I also want to know how I can make it work for the 6 digit format ie.

123456
to 12:34:56. Thanks for your help.

Rob



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
Ref earlier post "Excel Time Calculation" jc Excel Discussion (Misc queries) 4 November 7th 07 08:32 PM
Solver Problem ( related to earlier post of using if an Vlookup) Honey Excel Worksheet Functions 1 April 19th 07 11:16 PM
disregard earlier post Jenny B. Excel Discussion (Misc queries) 2 March 22nd 07 06:11 PM
Chart Class Module/follow on question to hyperlink post earlier. Rominall Charts and Charting in Excel 2 March 7th 07 02:43 AM
Another syntax question (different from earlier post) Marty Excel Programming 3 March 6th 05 06:11 PM


All times are GMT +1. The time now is 10:18 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"