Date: prev next · Thread: first prev next last
2013 Archives by date, by thread · List index


On 02/09/2013 06:58 PM, Andrew Douglas Pitonyak wrote:
On 02/08/2013 05:15 PM, Joel Madero wrote:
Hi All,

I have a macro setup that can easily do the following:

pasteValue = mid(currentCellValue,1,4)

What is the format of "currentCellValue"? You grab the first four characters in your example above? Your code is dependent on how it is formatted.

a string is stored to pasteValue which I then can manipulate how I want.

What I want to do is make it actually more like this:

pasteValue =
date(value(mid(currentCellValue,1,4),value(mid(currentCellValue,5,2),value(mid(currentCellValue,8,2))

This won't work, there are so many things wrong with this, I won't even try to deal with what you did wrong. Instead, I will guess what you meant to do.

Curious why this works so well when in a cell....works exactly how I want it to. So, it must be possible to work in a macro as well.

I am guessing that you are using something like a four digit year, a two digit month, and then a two digit day. Is this correct? If so, then you can CDateFromIso(currentCellValue), and this will give you a date object directly and do all the work for you. This is the easiest solution I think.

currentCellValue is a string that is ##.##.####, again this is a string

If you really want to do the hard work and rip values out, you probably want to use

DateSerial(year, month, day)

In your case, it is probably:

DateSerial(mid(currentCellValue,1,4), mid(currentCellValue,5,2), mid(currentCellValue,7,2))

Your strings will be automatically converted to numbers, so you don't need to do it in your macro.

It needs to be done in macro, there is a big loop that it has to go through.

Disclaimer: This will return a number, which will not cause the cell to be formatted as a date; you must set the formatting to be a date.

This isn't a problem.


I'll try with what you've provided.


Thanks,
Joel

--
For unsubscribe instructions e-mail to: users+help@global.libreoffice.org
Problems? http://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: http://wiki.documentfoundation.org/Netiquette
List archive: http://listarchives.libreoffice.org/global/users/
All messages sent to this list will be publicly archived and cannot be deleted

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.