Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Formatting values populated by VB Code

I am getting data to show properly in the worksheets being populated by the
VB code, however, I need to convert it and do not know what to do in the VB
code to do this.

For example, I am copying times in seconds '2125' but need it to read in
HH:MM:SS format. I would usually do it in this method: = value/86400 OR
2125/86400 and then format the cell as 'HH:MM:SS' to show the value of:
0:35:25.

Is there something I can do after copying the cell and before its applied to
the cell its supposed to go into?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Formatting values populated by VB Code

You need to convert seconds to days by dividing by 86400. The format the
cell using this VBA code

Range("A1").numberformat = "HH:MM:SS"

"Dakota" wrote:

I am getting data to show properly in the worksheets being populated by the
VB code, however, I need to convert it and do not know what to do in the VB
code to do this.

For example, I am copying times in seconds '2125' but need it to read in
HH:MM:SS format. I would usually do it in this method: = value/86400 OR
2125/86400 and then format the cell as 'HH:MM:SS' to show the value of:
0:35:25.

Is there something I can do after copying the cell and before its applied to
the cell its supposed to go into?

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Formatting values populated by VB Code

Joel,

I know I need to convert it but how to I divide the cell value the VBA code
is getting and format it before its copied to a new sheet?

Here is the code I have now:

If sh.Cells(2, "B").Value = cell Then
fDate = cell.Offset(0, 1).Value
cell.Offset(0, 8).Copy
Set c = sh.Range("A15:A45").Find(fDate, LookIn:=xlValues)
Range("A1").numberformat = "HH:MM:SS"
sh.Range("C" & c.Row).PasteSpecial xlPasteValues

This copies it as 'general' and shows '2125' in the cell. I need to to show
0:35:25


"Joel" wrote:

You need to convert seconds to days by dividing by 86400. The format the
cell using this VBA code

Range("A1").numberformat = "HH:MM:SS"

"Dakota" wrote:

I am getting data to show properly in the worksheets being populated by the
VB code, however, I need to convert it and do not know what to do in the VB
code to do this.

For example, I am copying times in seconds '2125' but need it to read in
HH:MM:SS format. I would usually do it in this method: = value/86400 OR
2125/86400 and then format the cell as 'HH:MM:SS' to show the value of:
0:35:25.

Is there something I can do after copying the cell and before its applied to
the cell its supposed to go into?

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Formatting values populated by VB Code

If sh.Cells(2, "B").Value = cell Then
fDate = cell.Offset(0, 1).Value
cell.Offset(0, 8).Copy
Set c = sh.Range("A15:A45").Find(fDate, LookIn:=xlValues)
Range("A1").numberformat = "HH:MM:SS"
sh.Range("C" & c.Row).PasteSpecial xlPasteValues
sh.Range("C" & c.Row) = sh.Range("C" & c.Row)/86400

You don't need to copy instead
fDate = cell.Offset(0, 1).Value
Set c = sh.Range("A15:A45").Find(fDate, LookIn:=xlValues)
Range("A1").numberformat = "HH:MM:SS"
sh.Range("C" & c.Row) = cell.Offset(0, 8).value/86400




"Dakota" wrote:

Joel,

I know I need to convert it but how to I divide the cell value the VBA code
is getting and format it before its copied to a new sheet?

Here is the code I have now:

If sh.Cells(2, "B").Value = cell Then
fDate = cell.Offset(0, 1).Value
cell.Offset(0, 8).Copy
Set c = sh.Range("A15:A45").Find(fDate, LookIn:=xlValues)
Range("A1").numberformat = "HH:MM:SS"
sh.Range("C" & c.Row).PasteSpecial xlPasteValues

This copies it as 'general' and shows '2125' in the cell. I need to to show
0:35:25


"Joel" wrote:

You need to convert seconds to days by dividing by 86400. The format the
cell using this VBA code

Range("A1").numberformat = "HH:MM:SS"

"Dakota" wrote:

I am getting data to show properly in the worksheets being populated by the
VB code, however, I need to convert it and do not know what to do in the VB
code to do this.

For example, I am copying times in seconds '2125' but need it to read in
HH:MM:SS format. I would usually do it in this method: = value/86400 OR
2125/86400 and then format the cell as 'HH:MM:SS' to show the value of:
0:35:25.

Is there something I can do after copying the cell and before its applied to
the cell its supposed to go into?

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
Conditional Formatting dependent on whether cell is populated. Tel Excel Discussion (Misc queries) 3 January 20th 10 03:25 PM
Function Not Recognising Values in Populated Ranges Matt Roberts Excel Programming 0 January 11th 06 03:30 PM
Conditional formulas: color code text populated cells? TKT Excel Worksheet Functions 6 October 29th 05 02:15 AM
HELP! - Printing a sheet with values populated from dropdown box Co-op Bank Excel Programming 5 July 13th 05 02:23 PM
Copy Values to Below last Populated Cell Q John Excel Programming 2 June 29th 04 05:28 PM


All times are GMT +1. The time now is 08:27 AM.

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

About Us

"It's about Microsoft Excel"