Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I found this code on this NG and used it successfully several times.
But I have modified it slightly, to use a different formula and It returns an error: Application Defined or Object Defined Error. I don't know what this means. This is the code which I sourced from Don Guillet: Sub balance()' I use for a running balance in a checkbook. Set frng = Range("b3:b" & Range("a65536").End(xlUp).Row) With frng ..Formula= "vlookup(a1,sheet2!a2:z200,2,false)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub This is my modified code: Sub Balance() Set frng = Range("L4:L" & Range("B65536").End(xlUp).Row) With frng ..Formula = "=IF(K4=1,"",F4-D4)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub I have used several successful variations to my version of the code, but this formula "=IF(K4=1,"",F4-D4)" gives me the problem. I don't know much about writing macros. Can anyone offer an explanation and a fix for this please. Cheers Paul |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Try taking out the first or second '.' in
...Formula = "=IF(K4=1,"",F4-D4)" Best of luck DavidC -----Original Message----- I found this code on this NG and used it successfully several times. But I have modified it slightly, to use a different formula and It returns an error: Application Defined or Object Defined Error. I don't know what this means. This is the code which I sourced from Don Guillet: Sub balance()' I use for a running balance in a checkbook. Set frng = Range("b3:b" & Range("a65536").End(xlUp).Row) With frng ..Formula= "vlookup(a1,sheet2!a2:z200,2,false)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub This is my modified code: Sub Balance() Set frng = Range("L4:L" & Range("B65536").End(xlUp).Row) With frng ..Formula = "=IF(K4=1,"",F4-D4)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub I have used several successful variations to my version of the code, but this formula "=IF(K4=1,"",F4-D4)" gives me the problem. I don't know much about writing macros. Can anyone offer an explanation and a fix for this please. Cheers Paul . |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Paul,
You need to double the double quotes. Replace: .Formula = "=IF(K4=1,"",F4-D4)" with .Formula = "=IF(K4=1,"""",F4-D4)" --- Regards, Norman "Paul" wrote in message om... I found this code on this NG and used it successfully several times. But I have modified it slightly, to use a different formula and It returns an error: Application Defined or Object Defined Error. I don't know what this means. This is the code which I sourced from Don Guillet: Sub balance()' I use for a running balance in a checkbook. Set frng = Range("b3:b" & Range("a65536").End(xlUp).Row) With frng .Formula= "vlookup(a1,sheet2!a2:z200,2,false)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub This is my modified code: Sub Balance() Set frng = Range("L4:L" & Range("B65536").End(xlUp).Row) With frng .Formula = "=IF(K4=1,"",F4-D4)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub I have used several successful variations to my version of the code, but this formula "=IF(K4=1,"",F4-D4)" gives me the problem. I don't know much about writing macros. Can anyone offer an explanation and a fix for this please. Cheers Paul |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks very much Norman.
That did the trick. And thanks to DavidC for replying also. Cheers Paul "Norman Jones" wrote in message ... Hi Paul, You need to double the double quotes. Replace: .Formula = "=IF(K4=1,"",F4-D4)" with .Formula = "=IF(K4=1,"""",F4-D4)" --- Regards, Norman "Paul" wrote in message om... I found this code on this NG and used it successfully several times. But I have modified it slightly, to use a different formula and It returns an error: Application Defined or Object Defined Error. I don't know what this means. This is the code which I sourced from Don Guillet: Sub balance()' I use for a running balance in a checkbook. Set frng = Range("b3:b" & Range("a65536").End(xlUp).Row) With frng .Formula= "vlookup(a1,sheet2!a2:z200,2,false)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub This is my modified code: Sub Balance() Set frng = Range("L4:L" & Range("B65536").End(xlUp).Row) With frng .Formula = "=IF(K4=1,"",F4-D4)" ' .Formula = "=h7+d8" .Formula = .Value 'changes the formula to value End With End Sub I have used several successful variations to my version of the code, but this formula "=IF(K4=1,"",F4-D4)" gives me the problem. I don't know much about writing macros. Can anyone offer an explanation and a fix for this please. Cheers Paul |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
split post code (zip code) out of cell that includes full address | Excel Discussion (Misc queries) | |||
Code to conditional format all black after date specified in code? | Excel Discussion (Misc queries) | |||
Drop Down/List w/Code and Definition, only code entered when selec | Excel Worksheet Functions | |||
Convert a Number Code to a Text Code | Excel Discussion (Misc queries) | |||
VBA code delete code but ask for password and unlock VBA protection | Excel Programming |