Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default printing time literally

Hi

I'm printing data from an excel sheet to a text file, and some of
these cells contain Time's. However, printing the cell results in a number
between 0 and 1 rather than the exact string, eg "12:30" or "4:00". How can
I print it like that anyway?

Thanks
Bart



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 132
Default printing time literally

Hi Bart;

You could try converting the values in the time based
cells to strings. Then when you print them to a text file
they will not show up as numbers.

Thanks,

Greg
-----Original Message-----
Hi

I'm printing data from an excel sheet to a text file, and

some of
these cells contain Time's. However, printing the cell

results in a number
between 0 and 1 rather than the exact string, eg "12:30"

or "4:00". How can
I print it like that anyway?

Thanks
Bart



.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 770
Default printing time literally

Bart,

This will convert the value of the time to a string, held in the variable.
I then had to format the cell as text and then set the cell's value to the
string. After printing I formatted back to original format and reset the
value again - otherwise it didn't take.

Sub test()
Dim date_str As String
Dim cell_format As String

With Worksheets("Sheet1").Range("A1")
cell_format = .NumberFormat
date_str = CStr(Hour(.Value) & ":" & Minute(.Value))
.NumberFormat = "@"
.Value = date_str
'print to text file here
.NumberFormat = cell_format
.Value = date_str
End With
End Sub

"Bart van den Burg" wrote in message
...
Hi

I'm printing data from an excel sheet to a text file, and some of
these cells contain Time's. However, printing the cell results in a number
between 0 and 1 rather than the exact string, eg "12:30" or "4:00". How

can
I print it like that anyway?

Thanks
Bart





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
Copying a formula "literally" ArthurJ Excel Discussion (Misc queries) 8 February 7th 06 08:35 PM
page set up on excel to get 100% @ time of printing music icons Setting up and Configuration of Excel 0 January 10th 06 08:40 PM
EVERY Chord, Scale and Mode for GUITAR.. Literally!! Open Minded215 Excel Worksheet Functions 0 January 26th 05 08:58 AM
Literally displaying imported cells with and tags [email protected] Excel Discussion (Misc queries) 3 January 13th 05 11:54 PM
Literally - every other time Steph[_3_] Excel Programming 0 June 9th 04 08:50 PM


All times are GMT +1. The time now is 11:47 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"