Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pivot Output formatting.
I have pivot table output from stored procedure via
VBScript. I'd like the greatest value per row to be highlighted in red. Network CHAN Devi CHAN 19343 8864 Devi 8864 31942 And where CHAN = CHAN I'd like the cell bold, Devi = Devi same, and on down the rest of the pivot output. Any input would be welcomed. B |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pivot Output formatting (code)
Public Sub NetworkCrossCheck()
Dim rsReport As New ADODB.Recordset Dim cnReport As New ADODB.Connection Dim cmdReport As New ADODB.Command Dim lrow As Long Dim lCol As Long Dim pc As PivotCache Dim pt As PivotTable Dim wb As Workbook On Error GoTo NetworkCrossCheckError cnReport.ConnectionString = "DSN=CM_Mod3SQL_DEV;" cnReport.CursorLocation = adUseClient cnReport.Open If (cnReport.State < adStateOpen) Then MsgBox "Database connection not open, cannot run query" Exit Sub End If Set cmdReport.ActiveConnection = cnReport cmdReport.CommandText = "rpt_NetworkCrossCheck_sp" cmdReport.CommandType = adCmdStoredProc cmdReport.CommandTimeout = 300 Set rsReport = cmdReport.Execute Set wb = Workbooks.Open(sPath & "NetworkCrossCheck_template.xls", 0, True) Set pc = ActiveWorkbook.PivotCaches.Add (SourceType:=xlExternal) Set pc.Recordset = rsReport pc.CreatePivotTable TableDestination:=Range("A3"), TableName:="Network Cross Check" With ActiveSheet.PivotTables("Network Cross Check") .SmallGrid = False .RowGrand = False .ColumnGrand = False With .PivotFields("NetworkName") .Orientation = xlRowField .Position = 1 End With With .PivotFields("NetworkName1") .Orientation = xlColumnField .Position = 1 End With With .PivotFields("TaxID") .Orientation = xlDataField .Position = 1 End With End With Set rsReport = Nothing Set cmdReport = Nothing Set cnReport = Nothing Set wb = Nothing 'cnReport.Close Exit Sub NetworkCrossCheckError: MsgBox CStr(Err.Number) & ": " & Err.Description & vbCrLf & "Please call support", vbExclamation, "NetworkCrossCheck" Resume Next End Sub |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pivot Output formatting.
Bee wrote:
I'd like the greatest value per row to be highlighted in red. Sounds like a job for conditional formatting Select the data area of the pivot table Say the top left cell is B4 Format / Conditional Formatting / Formula Is / =B4=MAX(4:4) / Format / Font / Red / OK... Add / Formula Is / =B$3=$A4 / Format / Font / Bold / OK / OK If you recorded a macro while doing that you could incorporate it in your code. Bill Manville MVP - Microsoft Excel, Oxford, England No email replies please - reply in newsgroup |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Pivot Output formatting.
Cool Bill. Thanks. I will give this a try.
Regards, B. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Formatting Output Range in Combo Box | Excel Discussion (Misc queries) | |||
Formatting text output within formulas | Excel Worksheet Functions | |||
conditional formatting w/ color as input vs output | Excel Worksheet Functions | |||
Can I pull field as datafield or as a output from a pivot table re | Excel Discussion (Misc queries) | |||
Formatting equation output | Excel Programming |