Help Converting VBA code to LibreOffice Calc code

Mike Guest98

New Member
Joined
Jun 4, 2018
Messages
42
I have working VBA code that I have rewritten to be used in LibreOffice Calc but it’s not working. The VBA code is searching through three ranges of cells for any sets of numbers (eg 1-15 or 3-99) where the second number is 19 or higher and then it does a count which is written to cell E18. I have the VBA code below and the non working Cal code below that.



Do you know why it’s not working. If you have any questions please ask. Thank you for looking.


Working VBA code


Sub Locate19PLUSnumbers()


Dim rng As Range, c As Range

Set rng = Range("E23:E175,J23:J175,O23:O175")

With CreateObject("scripting.dictionary")

For Each c In rng

If Val(Mid(c, InStr(1, c, "-") + 1)) > 19 Then .Item(c.Address(0, 0)) = Empty

Next

If .Count = 0 Then [E18] = 0 Else [E18].Resize(.Count) = Application.Transpose(.Keys)

End With

MsgBox "Finished"

End Sub





(Non-Working) LibreOffice Calc Code – Version 6.1.5.2


Sub Locate19PLUSnumbers()

Dim rng As Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1), c As Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)

Set rng = Dim oSheet as Object[n]oSheet = ThisComponent.CurrentController.ActiveSheet[n]oSheet.getCellRangeByName($1)("E23:E175,J23:J175,O23:O175")

With CreateObject("scripting.dictionary")

For Each c In rng

If Val(Mid(c, InStr(1, c, "-") + 1)) > 19 Then .Item(c.Address(0, 0)) = Empty

Next

If .Count = 0 Then [E18] = 0 Else [E18].Resize(.Count) = Application.Transpose(.Keys)

End With

MsgBox "Finished"
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Please delete post.
We typically only delete posts if private/sensitive data is posted.

If you no longer need an answer, just replying back saying something to that effect is sufficient (if you have a solution, we usually advise people to post the solution in case others with similar questions come upon this thread).
 
Upvote 0

Forum statistics

Threads
1,223,983
Messages
6,175,778
Members
452,668
Latest member
mrider123

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top