Cel adres van de hoogste waarde

Status
Niet open voor verdere reacties.

OpenWorld

Nieuwe gebruiker
Lid geworden
22 jan 2007
Berichten
1
Stel, ik heb een 2 koloms tabel, 1 met de datum de andere met een waarde.

Nu wil ik als resultaat in een cel de datum die behoort bij de hoogste waarde (hint: zelfde rij).

Ik heb geen probleem met het vinden van de hoogste waarde uit een kolom, maar ik kom er niet achter hoe ik het adres van die cel krijg.

Ik heb al wat met INDIRECT en ADRES zitten stoeien, maar krijg niet het gewenste resultaat... :(
 
Andrew Pitonyak schreef een document waarin onder meer de menselijk leebare vorm van CellAddress aan bod komt.

Hij schreef onder meer:

--citaat Andrew Pitonyak:
Human readable address of cell
The com.sun.star.table.CellAddressConversion service can be used to obtain a human readable text string that represents the address of a cell. I have not found any documentation on this service, but as of OOo 1.1.1, it seems to work well enough. The following code snippet assumes that the current document is a Calc document, and that only a single cell is selected.


Listing 6.8: Cell address in a readable form using CellAddressConversion.
Code:
  oActiveCell = ThisComponent.getCurrentSelection()
  oConv = ThisComponent.createInstance("com.sun.star.table.CellAddressConversion")
  oConv.Address = oActiveCell.getCellAddress
  Print oConv.UserInterfaceRepresentation
  Print oConv.PersistentRepresentation

I created the following function before I knew about the CellAddressConversion service.
Listing 6.9: Cell address in a readable form.

Code:
'Given a cell, extract the normal looking address of a cell
'First, the name of the containing sheet is extracted.
'Second, the column number is obtained and turned into a letter
'Lastly, the row is obtained. Rows start at 0 but are displayed as 1
Function PrintableAddressOfCell(the_cell As Object) As String
  PrintableAddressOfCell = "Unknown"
  If Not IsNull(the_cell) Then
    PrintableAddressOfCell = the_cell.getSpreadSheet().getName + ":" + _
      ColumnNumberToString(the_cell.CellAddress.Column) + (the_cell.CellAddress.Row+1)
  End If
End Function

' Columns are numbered starting at 0 where 0 corresponds to A
' They run as A-Z,AA-AZ,BA-BZ,...,IV
' This is esentially a question of how do you convert a Base 10 number to
' a base 26 number. 
' Note that the_column is passed by value!
Function ColumnNumberToString(ByVal the_column As Long) As String
  Dim s$
  'Save this so I do NOT modify the parameter.
  'This was an icky bug that took me a while to find
  Do while the_column >= 0
    s$ = Chr(65 +  the_column MOD 26) + s$
    the_column =  the_column \ 26 - 1
  Loop 
  ColumnNumberToString = s$
End Function
-----einde citaat Andrew Pitonyak-----

Er staan nog veel meer voorbeelden in zijn macroducument. Google maar eens op Pitonyak :thumb:
 
Stel dat de data in kolom A staan en de andere gegevens in kolom B pas dan deze formule toe:
Code:
=INDEX(A1:B5;VERGELIJKEN(MAX(B1:B5);B1:B5;1);1)
 
Status
Niet open voor verdere reacties.
Terug
Bovenaan Onderaan