Skip to main content

Posts

Showing posts from May, 2012

Calling a macro from a macro that displays a chart.

Calling a macro from a macro that displays a chart. Once the chart is created, should the user click on the chart it will execute a macro. Sub TestAssignMacro() ' Reference ChartObject by Name ActiveSheet.ChartObjects("Chart 1").OnAction = _ "CopyChartWithRatio" ' ... or reference ChartObject by Index (it's the same) ActiveSheet.ChartObjects(1).OnAction = _ "CopyChartWithRatio" End Sub Sub CopyChartWithRatio() ' When you click Chart, this macro will run MsgBox "Hi from Chart" End Sub

Highlighti​ng Duplicates Based On Two Columns in Excel

When your requirements were simply to detect repeated occurrences of the value in Column C, I suggested using conditional formatting with the formula: =MATCH(C1,C:C,0)<>ROW(C1) Now you have extended the requirements to detect only those cases where the description (in Column D) is different. That simply means extending the formula to something like: =AND(MATCH(C1,C:C,0)<>ROW(C1),OFFSET($D $1,MATCH(C1,C:C,0)-1,0)<>D1) The point is that you can achieve the desired results entirely with nothing more than a conditional format.

Compare Values in the Same Column in sql

Need to locate customers who has placed their orders twice in a certain period. Now, the order might not be exactly the same, thus  cant use a normal query finding duplications, but rather compare the order values of a customer and indicate the orders whose values differ with about 20%.. the simplest would be select t1.customerid,t1.orderid,t1.ordervalue ,t2.ordervalue from Table1 as T1 join Table1 as T2 on t1.orderid <> t1.orderid and t1.customerid = t2.customerid and t1.ordervalue < t2.ordervalue * 1.2 and t1.ordervalue > t2.ordervalue * .8