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

Date sent:60;Fri, 14 Mar 2025 23:35:49 -0400To:0;LibreOffice-list 
<[email protected]>
From:&#160;James &lt;[email protected]>
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: [email protected]
> 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:[email protected]&#160;
mailto:[email protected]
mailto:[email protected]
Guam - Where America's Day Begins&#160;
G4L Disk Imaging Project maintainer
http://sourceforge.net/projects/g4l/
+------------------------------------------------------------+




-- 
To unsubscribe e-mail to: [email protected]
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

Reply via email to