Assist in VBA Code using loop in EXCEL

wesleypeter

New Member
Joined
Feb 5, 2010
Messages
3
I have date and time in the format "01/00/1900 7:47:41 AM" from cell F2 to F80. The date remains teh same in every cells but the time varies. I want to use a macro to convert the every date to "01/01/1900" and keep the time unchanged. I use Excel 2003.

Can anyone assist me with the macro. Revert for further queries if any.
 

Excel Facts

Excel Wisdom
Using a mouse in Excel is the work equivalent of wearing a lanyard when you first get to college
If you have "01/00/1900 7:47:41 AM" in a cell, it is not a true date and time. It is text. There is no such date as "01/00/1900".
Just for reference, would "01/00/1900" be month zero or day zero?
 
Upvote 0
Thank you John for your reply. I know that the date is not a realy one but just a dummy date displayed. But my main concern is about the time displayed. "01/00/1900 7:47:41 AM" is the format that I receive from a report that I pull from an application. Is it possible to change only the date to " 01/01/1900" and keep the time intact? If so, please assist.
 
Upvote 0
VBA excel sees date in the number of days after 1/1/1900. Time, thus is stored in the decimal part. Therefore, if you only take the decimals and put it into a cell with date format, you will only get a time with date 1/1/1900. (I don't think John's case is necessarily true, though it is completely possible)

Read more on:
http://www.ozgrid.com/Excel/ExcelDateandTimes.htm

____________________________________________________________

If what John says it true (i.e. it is text), it is still very easy to manipulate the string by using these functions:
- Split
- Left
- Right
It will take a little long to run if there are lots of data, but it is doable.

Read about these functions on:
http://www.techonthenet.com/excel/formulas/index_vba_alpha.php (Left right)
http://visualbasic.about.com/od/learnvb6/l/blvbsplit.htm (Split)
 
Last edited:
Upvote 0

Forum statistics

Threads
1,216,466
Messages
6,130,795
Members
449,593
Latest member
morpheous

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top