I am trying to add conditional formatting on my pivot table created from Epplus bu i am not able to do it.
I can add the column colors on regular excel sheet by
using (var range = Pws.Cells[1,1,5,5])
{
range.Style.Fill.PatternType = ExcelFillStyle.Solid;
range.Style.Fill.BackgroundColor.SetColor(colorValue);
}
But when i add the code on pivot table sheet and try to open it it gives a pop up message like "Do you want to replace the content of the destination cell in PivotTable?"
I think its adding the color on top of the pivot table value. Its my guess because i can see the value of pivot table when i dont add the color formatting.
Any one had this issue and is there any work around?
Related
I have this data table that updates everyday with new data and the pivot table and slicer refresh automatically through a macro. Now, I wanted to write a macro to select the newly added slicer option and deselect the previous option, while not messing with the other earlier options that are also selected (multi-select slicer). The way I was going about it was to count the number of slicer items and then pass that index number to SlicerItems(i).select = True for the desired options. But it looks like you can only pass an array to data model based pivot slicer?
Here's my code
n = ActiveWorkbook.SlicerCaches("Slicer_Date").SlicerCacheLevels(1).SlicerItems.Count
'tried this
ActiveWorkbook.SlicerCaches("Slicer_Date").SlicerItems(n).Selected = True
'also tried this format
ActiveWorkbook.SlicerCaches("Slicer_Date").SlicerCacheLevels(1).SlicerItems(n - 3).Selected = False
Is there any workaround to pass the item number or any other way to accomplish this? Thanks!
i have a table for product in power bi. It has a column called sales rate.it has a text value “high,medium,low”.i want to add a conditional formatting to it. If it is high,the background of a cell should be red.if it is medium, background of a cell should be yellow.otherwise it will be green. How i can do it? And is it possible to use switch function with text?
You can make a new column, like this:
Column = SWITCH('Table'[Sales rate]; "high"; "red"; "medium"; "yellow"; "low"; "green")
Then right click each of the fields in Visualizations pane and select Conditional formatting -> Background color:
Format it by Field value, based on the column made, with First summarization, and you will get the highlighting you want:
See Use conditional formatting in tables for more information.
I've exported a DevExpress grid in Excel. I want to be able to apply Excel filters on exported Excel sheet. Right now, the Excel export only allows me to apply filters on values between dark grey rows (rows that already have sums in them). See pics.
(Could this be because of the cell merge that happened in the formatting?)
I'm using a the following method to export:
Using link As New PrintableComponentLink(New PrintingSystem())
Dim options As New XlsxExportOptionsEx
options.ExportType = DevExpress.Export.ExportType.DataAware
options.TextExportMode = TextExportMode.Value 'Should set to Value to be able to have the numbers displayed as numbers instead of text.
options.AllowCellMerge = DefaultBoolean.False
link.Component = gcInvisibleDetail
link.CreateDocument(link.PrintingSystem)
link.ExportToXlsx(tbRepertoire.Text & "\Charges.xlsx", options)
End Using
The filter Cannot be apply to whole columns because there is a small indents on the top and at the bottom within the group footer row 7,9,15 and 17 in your example, empty rows in Excel emulate these indents.
These rows are added to support the WYSIWYG principe of the grid export.
You can review this topic:
Problem with XtraGrid Group Footer rending when exporting to excel
I have created a pivot table that lists the number of visitors to a store on a given date. There are 3 columns of data, the date column and two columns of numbers representing the visitors. When I create a chart from this data I get a bar of data that represents dates before and after the range of dates that make up the data. I can suppress all dates that occur prior to the dates I want to view by using the command:
With Worksheets("Pivot Tables").PivotTables("Weekly Statistics").PivotFields("Date")
.PivotItems.Item(1).Visible = False
However, I can't find a way to suppress the dates that occur after today's date. This leaves me with a column on my bar chart that is blank and has the axis value ">3/27/2013". I can suppress it by actually typing this line:
.PivotItems.Item(">3/27/2013").Visible = False
but having to manually do this every time I update the sheet is laborious and makes the sheet unusable to anyone else.
I tried to create a variable that would update the value inside the () but I can't get it to work.
Dim t
t = Worksheets("Data").Range("i3").Value
.PivotItems.Item(t).Visible = False
(where i3 is a cell in the Worksheet("Data") that is a concatenation of the date; in this case the cell contents are ">3/27/2013" )
Thanks
You could try to use alternative filtering technique:
t="3/27/2013"
Worksheets("Pivot Tables").PivotTables("Weekly Statistics").PivotFields("Date").PivotFilters.Add Type:=xlBefore, Value1:=t
However, it is used as of Excel 2007.
If not working try to start with:
Worksheets("Pivot Tables").PivotTables("Weekly Statistics").PivotFields("Date").ClearAllFilters
I have a user form in excel with a combo box and when I choose something in the combobox it automatically updates a pivot table in a certain sheet.
now I want to take all the fields that are now in the pivot table and copy them to another coulmn. I need to write it in vb but for some reason it wont copy the cells. that is my code:
Set x = ActiveSheet.PivotTables("PivotTable4.1").DataBodyRange.Cells
x.Copy
Application.Goto Reference:="pivot_paste"
x.Paste
everthing works fine except the last line for some reason
please help
x.Paste means to copy it to the range x, which is clearly not what you want. Something like this should work:
Set x = ActiveSheet.PivotTables("PivotTable4.1").DataBodyRange.Cells
x.Copy Destination:=ActiveSheet.Range("pivot_paste")