Hi Michael
I did something similar by help of a mixture of Analysis API and VBA
1.
In your workbook define in "this workbook the following declarations:
Public iFirstRow As Integer, iLastRow As Integer, iFirstColumn As Integer, iLastColumn As Integer
' defined in ThisWorkbook
Public Sub Workbook_SAP_Initialize()
' register callbacks
Call Application.Run("SAPExecuteCommand", "RegisterCallback", "AfterRedisplay", "Callback_AfterRedisplay")
End Sub
2.
then define a module with the macro ( User Exiit)
Public iFirstRow As Integer, iLastRow As Integer, iFirstColumn As Integer, iLastColumn As Integer
' defined in a module
Public Sub Callback_AfterRedisplay()
'THis is a User Exit for Analysis Office
myDimension ' get the dimensions of your crosstab
Undeline_Header ' Underline the first row
End Sub
3. define a function (you call in upper macro to detect the dimensions(rows, columns) of your data
Function myDimension()
'this allows to modify your crosstab by rows. columns and offsets
iFirstRow = Range("SAPCrosstab1").Row
iLastRow = Range("SAPCrosstab1").Rows.Count + iFirstRow
iFirstColumn = Range("SAPCrosstab1").Column
iLastColumn = Range("SAPCrosstab1").Columns.Count + iFirstRow
End Function
4 .
last not least the function or sub (if you like to use a button like "underline"
Function Undeline_Header()
' you my skip the selection ans just purely address the range
Range(Cells(iFirstRow + 1, iFirstColumn), Cells(iFirstRow + 1, iLastColumn)).Select
With Selection.Borders(xlEdgeBottom)
.LineStyle = xlContinuous
.Color = -16777024
.TintAndShade = 0
.Weight = xlMedium
End With
End Function
THe result will look like my last picture.
By changing the offsets of first or any other variable, you may insert formatting or whatever Excel has to offer ![]()
Hope that may help you.
I did a lot of enhancements in BEx for the last 15 years by help of the (with 7x ) almost lost API
Many thanks to the Analysis Office developer crew taht you decided to have such a fantanstic API
Joerg Boeke