[Solved] VBA to LibreOffice question

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

[Solved] VBA to LibreOffice question

Post by comandos »

I need a little help editing my existing VBA code to work with libre office.

I would like:
1) to copy errors in column C if the date in the same row in yellow,
2) sort them all by date oldest to newest
3) (if possible) if the button (that triggers the macro is pressed it clears any previous entries in “STATUS” tab).
https://imgur.com/a/GQVmEPv ← example

code

Code: Select all

Option Compare Text
Sub getAllErr()
    Dim ws As Worksheet
    Dim lastRow As Integer
    For Each ws In ThisWorkbook.Sheets
        If ws.Name <> "status" Then
            For i = ws.UsedRange.Rows.Count To 2 Step -1
                If ws.Cells(i, 1).Interior.Color = 65535 Then
                    lastRow = ThisWorkbook.Sheets("status").Cells(Rows.Count, 1).End(xlUp).Row
                    ThisWorkbook.Sheets("status").Cells(lastRow + 1, 1) = Format(ws.Cells(i, 1), "Short Date")
                    ThisWorkbook.Sheets("status").Cells(lastRow + 1, 2) = ws.Name
                    ThisWorkbook.Sheets("status").Cells(lastRow + 1, 3) = ws.Cells(i, 3)
                End If
            Next i
        End If
    Next ws
End Sub

MsgBox "Kopirano"

BR
Last edited by Hagar Delest on Fri Mar 20, 2020 1:00 pm, edited 1 time in total.
Reason: tagged solved.
Libre office 6.4.0.3 on Windows 10
F3K Total
Volunteer
Posts: 1038
Joined: Fri Dec 16, 2011 8:20 pm

Re: VBA to libreoffice question

Post by F3K Total »

  • MMove 1.0.6
  • Extension for easy, exact positioning of shapes, pictures, controls, frames ...
  • my current system
  • Windows 10 AOO, LOLinux Mint AOO, LO
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to libreoffice question

Post by comandos »

F3K Total wrote:crossposting
It is I'm just looking for help, Should I delete the second post?
Libre office 6.4.0.3 on Windows 10
User avatar
robleyd
Moderator
Posts: 5085
Joined: Mon Aug 19, 2013 3:47 am
Location: Murbko, Australia

Re: VBA to LibreOffice question

Post by robleyd »

It is courteous to advise when cross posting and provide a link so people don't duplicate suggestions that have already been made elsewhere.
Cheers
David
OS - Slackware 15 64 bit
Apache OpenOffice 4.1.15
LibreOffice 24.2.2.2; SlackBuild for 24.2.2 by Eric Hameleers
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

robleyd wrote:It is courteous to advise when cross posting and provide a link so people don't duplicate suggestions that have already been made elsewhere.
My bad, sorry.
Libre office 6.4.0.3 on Windows 10
Bidouille
Volunteer
Posts: 577
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: VBA to LibreOffice question

Post by Bidouille »

No need macro, use a conditional formatting.
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

Bidouille wrote:No need macro, use a conditional formatting.
Please elaborate.
If I need to pull date from different sheets and the data changes. Sure I could apply conditional formatting after I have runed the macro but I would have to do this every time the macro is runed.
Libre office 6.4.0.3 on Windows 10
Bidouille
Volunteer
Posts: 577
Joined: Mon Nov 19, 2007 10:58 am
Location: France

Re: VBA to LibreOffice question

Post by Bidouille »

comandos wrote:Please elaborate.
Please provide a sample document.
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

Bidouille wrote:
comandos wrote:Please elaborate.
Please provide a sample document.
Attached the sample file
Attachments
reddit2.xlsm
(21.75 KiB) Downloaded 220 times
Libre office 6.4.0.3 on Windows 10
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: VBA to LibreOffice question

Post by mikele »

Hello,
is there a rule for the yellow date?
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

Yellow data marks the date of the error, the error is then written in column C for each device (devices are listed in tabs)
Libre office 6.4.0.3 on Windows 10
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: VBA to LibreOffice question

Post by mikele »

Hello,
but obviously not every error leads to a yellow date. Why?
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

I decide which error is important and mark them manually with yellow, I just need a macro that gathers all the yellow errors and presents them under »status«
Libre office 6.4.0.3 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: VBA to LibreOffice question

Post by Zizi64 »

I decide which error is important and mark them manually with yellow, I just need a macro that gathers all the yellow errors and presents them under »status«
Mark the errors by numbers in an independent column. Then you can sum them easily. Never use the formatting propeties as some "data" what you need handle in the future.
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

All I need is how to edit the existing macro to COPPY text from the designated field.

If anyone here can help that would be appreciated
Libre office 6.4.0.3 on Windows 10
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: VBA to LibreOffice question

Post by Zizi64 »

All I need is how to edit the existing macro to COPPY text from the designated field.
- Use ODF file types in the AOO/LO instead of the MS fileformats
- Rewrite all of your macros based on the StarBasic and the API functions of the AOO/LO,
because the VBA macros will nor run in AOO, and you can not store the Starbasic+API macros in an xlsm document (they will not run in Excel).
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

I can't code.
Libre office 6.4.0.3 on Windows 10
User avatar
RoryOF
Moderator
Posts: 34618
Joined: Sat Jan 31, 2009 9:30 pm
Location: Ireland

Re: VBA to LibreOffice question

Post by RoryOF »

None of us could - we had to learn. Needing to do something is a great incentive.
Apache OpenOffice 4.1.15 on Xubuntu 22.04.4 LTS
User avatar
Zizi64
Volunteer
Posts: 11360
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: VBA to LibreOffice question

Post by Zizi64 »

I can't code.
Then do not use macros in AOO/LO
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: VBA to LibreOffice question

Post by mikele »

Hi,
if you change one code line:

Code: Select all

ThisWorkbook.Sheets("status").Cells(lastRow + 1, 3) = ws.Cells(i, 3).Text
the macro works under LibreOffice.
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
comandos
Posts: 10
Joined: Mon Mar 16, 2020 1:14 pm

Re: VBA to LibreOffice question

Post by comandos »

mikele wrote:Hi,
if you change one code line:

Code: Select all

ThisWorkbook.Sheets("status").Cells(lastRow + 1, 3) = ws.Cells(i, 3).Text
the macro works under LibreOffice.
THANK YOU!
Libre office 6.4.0.3 on Windows 10
Post Reply