The following code works in Excel VBA but not in Calc LO Basic. The code moves a set of numbers (eg. 2-10 or 9-44) down one cell.
If you could please take a look and see what adjustments are needed. I can add the spreadsheet if that helps. Please let me know.
Thank-you.
- I’m using Cal Version: 6.4.7.2
- OS: Linux
Sub MOVE10PLUSDOWN()
Dim rng As Range, tmp, i As Long
'THE NUMBER SET COLUMN
Set rng = Range("B23:B45")
tmp = rng.Cells(rng.Cells.Count).Value
For i = rng.Cells.Count To 2 Step -1
rng.Cells(i).Value = Increment(rng.Cells(i - 1).Value)
Next i
rng.Cells(1).Value = Increment(tmp)
End Sub
'If value has a dash, increment the second number
Function Increment(v)
Dim rv, arr
rv = v
arr = Split(v, "-")
If UBound(arr) = 1 Then rv = arr(0) & "-" & CLng(arr(1)) + 1
Increment = rv
End Function
[erAck: edited to format as code, see This is the guide - How to use the Ask site? - #6 by erAck ]