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


=On 14 Mar 2025 at 23:35, James wrote:


Date sent:60;Fri, 14 Mar 2025 23:35:49 -0400To:0;LibreOffice-list 
<users@global.libreoffice.org>
From:&#160;James &lt;bjlockie@lockie.ca>
Subject:;[libreoffice-users] split 4 digits to time 
macro


I have a lot of times without the colon that I want to create a macro to
easily change them to 2 digit:2 digit.
I tried to record a macro but it hard coded the cell I recorded on.

Here's what it made:
REM ***** BASIC *****

Sub Main

End Sub


sub split_time
rem ----------------------------------------------------------------------
rem define variables
dim document as object
dim dispatcher as object
rem ----------------------------------------------------------------------
rem get access to the document
document = ThisComponent.CurrentController.Frame
dispatcher = createUnoService("com.sun.star.frame.DispatchHelper")

rem ----------------------------------------------------------------------
dim args1(0) as new com.sun.star.beans.PropertyValue
args1(0).Name = "ToPoint"
args1(0).Value = "$D$2387"

dispatcher.executeDispatch(document, ".uno:GoToCell", "", 0, args1())

rem ----------------------------------------------------------------------
dim args2(0) as new com.sun.star.beans.PropertyValue
args2(0).Name = "StringName"
args2(0).Value = "14:35"

dispatcher.executeDispatch(document, ".uno:EnterString";, "", 0, args2())


end sub
If I understant what you want correctly, this might work.


You didn't specify it numbers are in HH:MM or MM:SS?
If HH:MM value in A1 being less than 1, would already be a time 
value, below formula would just keep the current value, otherwise 
it would convert to time value with digits and minutes for the other, 
and setting seconds to 0.
=IF(A1>=1,TIME(INT(A1/100),MOD(A1,100),0),A1)


If is MM:SS then this formula should work.
=IF(A1>=1,TIME(0,INT(A1/100),MOD(A1,100)),A1)


Would do this in a different column than original, and then could 
highlight data, use Ctrl-C to Copy and Shift+Ctrl-V to paste the 
values. Should format cells to HH:MM or MM:SS to match what 
you want.

--
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/> Privacy Policy: 
https://www.documentfoundation.org/privacy




+------------------------------------------------------------+
Michael D. Setzer II - Computer Science Instructor (Retired)60;
mailto:mikes@guam.net&#160;
mailto:msetzerii@gmail.com
mailto:msetzerii@gmx.com
Guam - Where America's Day Begins&#160;
G4L Disk Imaging Project maintainer
http://sourceforge.net/projects/g4l/
+------------------------------------------------------------+




-- 
To unsubscribe e-mail to: users+unsubscribe@global.libreoffice.org
Problems? https://www.libreoffice.org/get-help/mailing-lists/how-to-unsubscribe/
Posting guidelines + more: https://wiki.documentfoundation.org/Netiquette
List archive: https://listarchives.libreoffice.org/global/users/
Privacy Policy: https://www.documentfoundation.org/privacy

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.