Change a Macro from Excel into Libre Calc

Dier Eluom
Dier Eluom used Ask the Experts™
Hi, I want to use this code in Libre Calc as a macro.  It is VB.  Is that possible?  How can I change it so that it works in Calc?

Private Sub Worksheet_Change(ByVal Target As Excel.Range)

Dim rCell As Range
    Dim rChange As Range
    On Error GoTo ErrHandler
    Set rChange = Intersect(Target, Range("A:A"))
    If Not rChange Is Nothing Then
        Application.EnableEvents = False
        For Each rCell In rChange
            If rCell > "" Then
                With rCell.Offset(0, 1)
                    .Value = Now
                    .NumberFormat = "hh:mm:ss"
                End With
                rCell.Offset(0, 1).Clear
            End If
    End If

    Set rCell = Nothing
    Set rChange = Nothing
    Application.EnableEvents = True
    Exit Sub
    MsgBox Err.Description
    Resume ExitHandler
End Sub
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Serena HsiMarketing Consultant

Here are some LibreCalc resources for creating macros:

LibreOffice Basic Programmer's Guide

LibreOffice Basic Macro Tutorial

Ten useful LibreOffice Macro Recipes (tutorial)

Andrew Pitonyak's OpenOffice Macro Information (examples)


I just found that code online.  I didn't write it.  However what it does is what I want a script to do in Libre Calc but I dont know how to write it.
Serena HsiMarketing Consultant

You could record a macro in LibreCalc to see what the syntax is like, then adapt it for your needs.
I found a simple formula that solved the problem. = IF(A15="","",IF(B15="",NOW(),B15))


It works.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial