Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.worksheet.functions
|
|||
|
|||
![]()
All,
i'e got some VB that is working beautifully putting in a formula on a sheet it then goes on to create various other sheets. The problem is I'm pretty new to VB have recorded little macro to do conditional formatting of cells and used (i thought) same rules, but always get compile error when I insert C formatting instructions after formula one. here is bit that works ActiveSheet.Name = "BB SCM " & FormatDateTime(Date, vbLongDate) myval = Application.CountIf(ActiveSheet.Cells, "NPQ") - 1 Range("Q6").Select ActiveCell.FormulaR1C1 = _ "=AVERAGE(IF(RC[-13]:RC[-2]0,RC[-13]:RC[-2],RC[-13]))" Range("Q6").Select Selection.FormulaArray = _ "=AVERAGE(IF(RC[-13]:RC[-2]0,RC[-13]:RC[-2],RC[-13]))" Dim counter As Integer For counter = 1 To myval Cells(6 + (counter * 8), 17).Select ActiveCell.FormulaR1C1 = _ "=AVERAGE(IF(RC[-13]:RC[-2]0,RC[-13]:RC[-2],RC[-13]))" Cells(6 + (counter * 8), 17).Select Selection.FormulaArray = _ "=AVERAGE(IF(RC[-13]:RC[-2]0,RC[-13]:RC[-2],RC[-13]))" Range("A6").Select ActiveCell.FormulaR1C1 = "Stk Wk" Range("B6").Select ActiveCell.FormulaR1C1 = "=IF(RC[15]0,R[-1]C[2]/RC[15],""NF"")" Range("B6").Select Selection.NumberFormat = "0.0" Cells(6 + (counter * 8), 1).Select ActiveCell.FormulaR1C1 = "Stk Wk" Cells(6 + (counter * 8), 2).Select ActiveCell.FormulaR1C1 = "=IF(RC[15]0,R[-1]C[2]/RC[15],""NF"")" Cells(6 + (counter * 8), 2).Select Selection.NumberFormat = "0.0" Range("Q1").Select Application.CutCopyMode = False ActiveCell.FormulaR1C1 = "Fc ave" Next counter here is bit for one cell that I wish to copy down to all releveant cells as above conditionalformatting Macro ' Macro recorded 12/10/2007 by jaberesf ' ' Range("B6").Select Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlLess, _ Formula1:="2" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = 3 End With Range("B7").Select Selection.FormatConditions.Delete Selection.FormatConditions.Add Type:=xlCellValue, Operator:=xlBetween, _ Formula1:="=""1.2*D6""", Formula2:="=""0.8*D6""" With Selection.FormatConditions(1).Font .Bold = True .Italic = False .ColorIndex = 3 End With |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Conditonal formatting | Excel Discussion (Misc queries) | |||
Self Tests, and Conditonal Formatting | Excel Discussion (Misc queries) | |||
How do I do Conditonal Formatting with formula progression | Excel Worksheet Functions | |||
Conditonal Formatting | Excel Discussion (Misc queries) | |||
Protect conditonal formatting | Excel Discussion (Misc queries) |