Hi
I have some code that I use for a small project I work on. I’m receiving the following error:
“BASIC syntax error
Sub procedure or function procedure Increment already defined”
on this line: Function Increment(v As Variant)
Can anyone spot where the problem is and how to fix it?
Thanks so much.
Sub Move1Range(sRangeAddress As String)
Dim oActiveSheet As Variant
Dim oCellRangeByName As Variant
Dim oDataArray As Variant, tmp As Variant
Dim i As Long, j As Integer
oActiveSheet = ThisComponent.getCurrentController().getActiveSheet()
oCellRangeByName = oActiveSheet.getCellRangeByName(sRangeAddress)
oDataArray = oCellRangeByName.getDataArray()
tmp = oDataArray(UBound(oDataArray))(0)
For i = UBound(oDataArray) To LBound(oDataArray)+1 Step -1
If Trim(oDataArray(i-1)(0))="" Then
oDataArray(i)(0) = ""
Else
oDataArray(i)(0) = Increment(oDataArray(i-1)(0))
EndIf
Next i
For i = LBound(oDataArray) To UBound(oDataArray)
For j = 1 To 3
oDataArray(i)(j) = ""
Next j
Next i
oDataArray(0)(0) = Increment(tmp)
oCellRangeByName.setDataArray(oDataArray)
End Sub
Function Increment(v As Variant) ‘ (problem here)
Dim rv As Variant, arr As Variant
rv = v
arr = Split(v, "-")
If UBound(arr) = 1 Then rv = arr(0) & "-" & CLng(arr(1)) + 1
Increment = rv
End Function