Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default VBA convert Time to Military in the same Column please


Hello from Steved

The objective is to Convert 1:05pm to 1305 please in the same Column.

I do not know enough experience to wright the macro to have the below working
Please help me.

Cells(SomeRow, SomeColumn).Value = Format(Cells(2, "C").Value,"hhmm")

Thankyou.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,934
Default VBA convert Time to Military in the same Column please


Is your "time" value a real time value formatted to appear **without** a
space between the numbers and the am/pm designation (as your example shows)?
Or is it a string value exactly as shown (that is, without the space)? Do
you want the result to be a real time value formatted to look like the
military time, or do you just want a 4-digit number (or possibly a
4-character string) that has nothing to do with a real Excel time value?

--
Rick (MVP - Excel)


"Steved" wrote in message
...
Hello from Steved

The objective is to Convert 1:05pm to 1305 please in the same Column.

I do not know enough experience to wright the macro to have the below
working
Please help me.

Cells(SomeRow, SomeColumn).Value = Format(Cells(2, "C").Value,"hhmm")

Thankyou.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,942
Default VBA convert Time to Military in the same Column please


hi
a small syntax problem. a value cannot equal a format.
try this
Cells(SomeRow, SomeColumn).NumberFormat = "hhmm"
you may want to use .....
Cells(SomeRow, SomeColumn).NumberFormat = "hh:mm;@"
this way it would look more like a real time instead of just a four digit
number.

regards
FSt1
"Steved" wrote:

Hello from Steved

The objective is to Convert 1:05pm to 1305 please in the same Column.

I do not know enough experience to wright the macro to have the below working
Please help me.

Cells(SomeRow, SomeColumn).Value = Format(Cells(2, "C").Value,"hhmm")

Thankyou.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 519
Default VBA convert Time to Military in the same Column please


Hello Rick from Steved

1:05 pm

In worksheet it is displayed as 13:05 "no spaces"

In formula Bar it is displayed as 1:05:00 p.m.

ok, In worksheet I would like it to be displayed as 1305 please

7:05 am

In worksheet it is displayed as 7:05 "no spaces"

In formula Bar it is displayed as 7:05:00 a.m.

ok, In worksheet I would like it to be displayed as 0705 please

Yes please 4-digit number

I Thankyou for taking timeout on my issue.





"Rick Rothstein" wrote:

Is your "time" value a real time value formatted to appear **without** a
space between the numbers and the am/pm designation (as your example shows)?
Or is it a string value exactly as shown (that is, without the space)? Do
you want the result to be a real time value formatted to look like the
military time, or do you just want a 4-digit number (or possibly a
4-character string) that has nothing to do with a real Excel time value?

--
Rick (MVP - Excel)


"Steved" wrote in message
...
Hello from Steved

The objective is to Convert 1:05pm to 1305 please in the same Column.

I do not know enough experience to wright the macro to have the below
working
Please help me.

Cells(SomeRow, SomeColumn).Value = Format(Cells(2, "C").Value,"hhmm")

Thankyou.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default VBA convert Time to Military in the same Column please


Worksheetfunction
=TEXT(A1,"HHMM")

VBA
=Format(Range("A1"),"hhmm")


If this post helps click Yes
---------------
Jacob Skaria


"Steved" wrote:

Hello Rick from Steved

1:05 pm

In worksheet it is displayed as 13:05 "no spaces"

In formula Bar it is displayed as 1:05:00 p.m.

ok, In worksheet I would like it to be displayed as 1305 please

7:05 am

In worksheet it is displayed as 7:05 "no spaces"

In formula Bar it is displayed as 7:05:00 a.m.

ok, In worksheet I would like it to be displayed as 0705 please

Yes please 4-digit number

I Thankyou for taking timeout on my issue.





"Rick Rothstein" wrote:

Is your "time" value a real time value formatted to appear **without** a
space between the numbers and the am/pm designation (as your example shows)?
Or is it a string value exactly as shown (that is, without the space)? Do
you want the result to be a real time value formatted to look like the
military time, or do you just want a 4-digit number (or possibly a
4-character string) that has nothing to do with a real Excel time value?

--
Rick (MVP - Excel)


"Steved" wrote in message
...
Hello from Steved

The objective is to Convert 1:05pm to 1305 please in the same Column.

I do not know enough experience to wright the macro to have the below
working
Please help me.

Cells(SomeRow, SomeColumn).Value = Format(Cells(2, "C").Value,"hhmm")

Thankyou.




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
Is there an XLS function to convert std time to Military time? Carl Excel Worksheet Functions 1 May 20th 09 09:48 PM
convert military time to regular hours Kathy Excel Worksheet Functions 1 April 25th 06 01:20 PM
Convert to Military time? telewats Excel Discussion (Misc queries) 2 March 13th 06 06:17 PM
How do I convert Military Time to minutes? Rachael Excel Worksheet Functions 1 January 6th 05 10:01 PM
Convert to military time - part II Carole O Excel Programming 6 August 14th 04 01:55 AM


All times are GMT +1. The time now is 03:25 PM.

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"