Home |
Search |
Today's Posts |
#10
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In this particular case I don't know why the recorded macro did not work, I
can't recreate the setup to test. It's not necessary first to assign the formula to a variable, it just makes things easier. Recorded macros merely record the results of keystrokes, including unnecessary select and activate. Generally it's better to adapt a macro after recording it. Regards, Peter T "JG" wrote in message ... Ding ding! We have a winner. That worked. Bonus question(s).... Why? Why can I key this, but not record it? Why can't I enter this directly into the VBE...why do I have to assign it to a variable first? "Peter T" wrote: OK I get the error you mentioned, start by rearranging like this - Sub test() Dim sFmla As String Dim rCell As Range Set rCell = Range("I2") sFmla = "=IF(INDIRECT(""RC8"", FALSE)=""Auto No Run"", IF(GETPIVOTDATA(""Comp Status"", TCCompositionAnalysis!$A$3, ""TC ID"", INDIRECT(""RC1"", FALSE), ""Comp Status"", ""Error"", ""ManAuto"", ""Auto""), ""Auto Error"", IF(GETPIVOTDATA(""Comp Status"", TCCompositionAnalysis!$A$3, ""TC ID"", INDIRECT(""RC1"", FALSE), ""Comp Status"", ""UnDev"", ""ManAuto"", ""Auto"")0, ""Auto UnDev"", IF(GETPIVOTDATA(""Comp Status"", TCCompositionAnalysis!$A$3, ""TC ID"", INDIRECT(""RC1"", FALSE), ""Comp Status"", ""Maint"", ""ManAuto"", ""Auto"")0, ""Auto Maint"", ""Eval This Row""))), IF(INDIRECT(""RC8"", FALSE)=""Run Auto"", """", """"))" rCell.Formula = sFmla End Sub The formula is the same as yours though you'll probably need to unwrap The main change is Formula vs your FormulaR1C1 That at least enables the formula to be entered though I have no idea if it will give the correct result, it's impossible for me to recreate your workbook. At a glance though "RC8" & RC1 don't look right, would expect a numeral after the R. Notice there's no need to 'Select' the cell (you'd need to qualify it further if it's not on the activesheet) You didn't need Option Explicit as you didn't use any variables. But if you use them, as in my example, best to head the module with Option Explicit, ie include it at the top of the module. Regards, Peter T |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Where has my typing bar gone? | Setting up and Configuration of Excel | |||
Get #### when typing | Excel Discussion (Misc queries) | |||
name typing | Excel Worksheet Functions | |||
Is there a better way (with less typing)? | Excel Programming | |||
Is there a better way (with less typing)? | Excel Programming |