Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I am attempting to load a formula from VB. I get an object defined error on
the final line of code below Dim formula_str As String Range(M4).Select formula_str = "=IF(ISERROR(VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE)),0,VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE))" ActiveCell.FormulaR1C1 = formula_str |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Without testing...
You wrote your formula in A1 reference style--not R1C1 reference style. ActiveCell.Formula = formula_str Michael wrote: I am attempting to load a formula from VB. I get an object defined error on the final line of code below Dim formula_str As String Range(M4).Select formula_str = "=IF(ISERROR(VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE)),0,VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE))" ActiveCell.FormulaR1C1 = formula_str -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I already tried the R1C1 style. That does not work either. It appears that
I will have to break the formula into two and use different columns. "Dave Peterson" wrote: Without testing... You wrote your formula in A1 reference style--not R1C1 reference style. ActiveCell.Formula = formula_str Michael wrote: I am attempting to load a formula from VB. I get an object defined error on the final line of code below Dim formula_str As String Range(M4).Select formula_str = "=IF(ISERROR(VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE)),0,VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE))" ActiveCell.FormulaR1C1 = formula_str -- Dave Peterson |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Maybe you should paste a copy of your code from the code window instead of
retyping it into the post. This line failed for me: Range(M4).Select It should be Range("M4").Select But your formula worked ok for me if I had a workbook named filename.xls open and changed the line to: ActiveCell.Formula = formula_str Michael wrote: I already tried the R1C1 style. That does not work either. It appears that I will have to break the formula into two and use different columns. "Dave Peterson" wrote: Without testing... You wrote your formula in A1 reference style--not R1C1 reference style. ActiveCell.Formula = formula_str Michael wrote: I am attempting to load a formula from VB. I get an object defined error on the final line of code below Dim formula_str As String Range(M4).Select formula_str = "=IF(ISERROR(VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE)),0,VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE))" ActiveCell.FormulaR1C1 = formula_str -- Dave Peterson -- Dave Peterson |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Sorry - The M4 "M4" was a typo. I have a variable in my actual code but did
not want to confuse the issue here. Removing the R1C1 from the ActiveCell.Formula line worked. Thank You "Dave Peterson" wrote: Maybe you should paste a copy of your code from the code window instead of retyping it into the post. This line failed for me: Range(M4).Select It should be Range("M4").Select But your formula worked ok for me if I had a workbook named filename.xls open and changed the line to: ActiveCell.Formula = formula_str Michael wrote: I already tried the R1C1 style. That does not work either. It appears that I will have to break the formula into two and use different columns. "Dave Peterson" wrote: Without testing... You wrote your formula in A1 reference style--not R1C1 reference style. ActiveCell.Formula = formula_str Michael wrote: I am attempting to load a formula from VB. I get an object defined error on the final line of code below Dim formula_str As String Range(M4).Select formula_str = "=IF(ISERROR(VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE)),0,VLOOKUP(A4,'[filename.xls]sheet1'!$A$2:$B$100,2,FALSE))" ActiveCell.FormulaR1C1 = formula_str -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
loading | Excel Discussion (Misc queries) | |||
add-ins not loading | Excel Programming | |||
Loading an xml | Excel Programming | |||
Loading Bar | Excel Programming | |||
Loading Bar | Excel Programming |