Seite 2 von 2

Re: Fehler bei Funktionsaufruf "Argument nicht optional"

Verfasst: Mi, 24.07.2024 17:42
von nobijohn
@mikeleb: Danke für den Hinweis.
@Karolus: Deine Funktion liefert fälschlich A zurück.

Hier mein bisheriges Ergebnis:
Die von mir pepostete Version funktioniert korrekt wenn man das If auskommentiert. Weiß jemand was es mit "bWithSheet" auf sich haben könnte?
Ich glaube nicht dass Pitonyak/Lenhardt 700 Seiten Stuss geschrieben haben. Google konnte mir nicht helfen.

sub main
Col = 123
Row = 4
print col_name(Col)
print AdressString(Col,Row)
print Colstring (Col)
end sub


Function AdressString(Col as long, Row)
Dim s$
Do
s = Chr$((Col Mod 26) + 65) & s
Col = Col \ 26 - 1
Loop Until Col = -1
'If bWithSheet Then 'Was bedeutet WithSheet???????????
AdressString = s & CStr(Row + 1)
'End If
End Function

function col_name( col_index ) '@Karolus: Das liefert A zurück!
with ThisComponent.Sheets(0)
col_name = .Columns( Col ).Name
end with
end function

Function ColString(Col as long )
Dim s$
Do
s = Chr$((Col Mod 26) + 65) & s
Col = Col \ 26 - 1
Loop Until Col = -1
'If bWithSheet Then
ColString = s
'End If
End Function

Und es geht auch ganz ohne Funktion:

Cell=Doc.getCurrentSelection().getCellAddress()
Row=Cell.Row
Col=Cell.column
Cell=Sheet.getCellByPosition(Col,Row)
Colname=Cell.getColumns.getByIndex(0).getName()
cellname=Colname+ltrim(str(Row+1))
startSum = Row
Print "Colname= "&Colname

Danke für eure Hilfe.

Re: Fehler bei Funktionsaufruf "Argument nicht optional"

Verfasst: Mi, 24.07.2024 18:37
von Karolus
@Karolus: Deine Funktion liefert fälschlich A zurück.
Welche Funktion, wie, und mit welchen Argument rufst du die auf?
Aber ist auch egal… spiel weiter!

Re: Fehler bei Funktionsaufruf "Argument nicht optional"

Verfasst: Do, 25.07.2024 14:39
von nobijohn
Sorry Karolus. Deine Funktion funktioniert sehr gut. Hatte einen Schreibfehler drin.