Very simple VBA error












0















I keep getting a syntax error in the following VBA function:





Function F_1(k_, x_)
F_1 = (x_^3 - 3.0 * k_ * x_^2 + 3.0 * k_^2 * x_ - (5.0/7.0) * k_^3) / SQR(x_ - k_)
End Function


Anybody know what's happening?










share|improve this question




















  • 1





    post your code as text, not as a screenshot. Who wants to decipher the tiny font and make sense of it?

    – teylyn
    Dec 17 '18 at 18:44











  • apologies @teylyn

    – Jake Rose
    Dec 17 '18 at 18:48











  • I think you cannot simply use SQR as it is a worksheet function, not a VBA function. You need to use something like Application.WorksheetFunction.SQR()

    – Aganju
    Dec 17 '18 at 19:04













  • @Aganju Sqr is a VBA function

    – davidmneedham
    Dec 17 '18 at 20:42











  • Also there will be a runtime error if x_ < k_

    – trapper
    Dec 19 '18 at 4:02
















0















I keep getting a syntax error in the following VBA function:





Function F_1(k_, x_)
F_1 = (x_^3 - 3.0 * k_ * x_^2 + 3.0 * k_^2 * x_ - (5.0/7.0) * k_^3) / SQR(x_ - k_)
End Function


Anybody know what's happening?










share|improve this question




















  • 1





    post your code as text, not as a screenshot. Who wants to decipher the tiny font and make sense of it?

    – teylyn
    Dec 17 '18 at 18:44











  • apologies @teylyn

    – Jake Rose
    Dec 17 '18 at 18:48











  • I think you cannot simply use SQR as it is a worksheet function, not a VBA function. You need to use something like Application.WorksheetFunction.SQR()

    – Aganju
    Dec 17 '18 at 19:04













  • @Aganju Sqr is a VBA function

    – davidmneedham
    Dec 17 '18 at 20:42











  • Also there will be a runtime error if x_ < k_

    – trapper
    Dec 19 '18 at 4:02














0












0








0








I keep getting a syntax error in the following VBA function:





Function F_1(k_, x_)
F_1 = (x_^3 - 3.0 * k_ * x_^2 + 3.0 * k_^2 * x_ - (5.0/7.0) * k_^3) / SQR(x_ - k_)
End Function


Anybody know what's happening?










share|improve this question
















I keep getting a syntax error in the following VBA function:





Function F_1(k_, x_)
F_1 = (x_^3 - 3.0 * k_ * x_^2 + 3.0 * k_^2 * x_ - (5.0/7.0) * k_^3) / SQR(x_ - k_)
End Function


Anybody know what's happening?







microsoft-excel vba






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 17 '18 at 18:54









Scott

15.6k113890




15.6k113890










asked Dec 17 '18 at 18:42









Jake RoseJake Rose

11




11








  • 1





    post your code as text, not as a screenshot. Who wants to decipher the tiny font and make sense of it?

    – teylyn
    Dec 17 '18 at 18:44











  • apologies @teylyn

    – Jake Rose
    Dec 17 '18 at 18:48











  • I think you cannot simply use SQR as it is a worksheet function, not a VBA function. You need to use something like Application.WorksheetFunction.SQR()

    – Aganju
    Dec 17 '18 at 19:04













  • @Aganju Sqr is a VBA function

    – davidmneedham
    Dec 17 '18 at 20:42











  • Also there will be a runtime error if x_ < k_

    – trapper
    Dec 19 '18 at 4:02














  • 1





    post your code as text, not as a screenshot. Who wants to decipher the tiny font and make sense of it?

    – teylyn
    Dec 17 '18 at 18:44











  • apologies @teylyn

    – Jake Rose
    Dec 17 '18 at 18:48











  • I think you cannot simply use SQR as it is a worksheet function, not a VBA function. You need to use something like Application.WorksheetFunction.SQR()

    – Aganju
    Dec 17 '18 at 19:04













  • @Aganju Sqr is a VBA function

    – davidmneedham
    Dec 17 '18 at 20:42











  • Also there will be a runtime error if x_ < k_

    – trapper
    Dec 19 '18 at 4:02








1




1





post your code as text, not as a screenshot. Who wants to decipher the tiny font and make sense of it?

– teylyn
Dec 17 '18 at 18:44





post your code as text, not as a screenshot. Who wants to decipher the tiny font and make sense of it?

– teylyn
Dec 17 '18 at 18:44













apologies @teylyn

– Jake Rose
Dec 17 '18 at 18:48





apologies @teylyn

– Jake Rose
Dec 17 '18 at 18:48













I think you cannot simply use SQR as it is a worksheet function, not a VBA function. You need to use something like Application.WorksheetFunction.SQR()

– Aganju
Dec 17 '18 at 19:04







I think you cannot simply use SQR as it is a worksheet function, not a VBA function. You need to use something like Application.WorksheetFunction.SQR()

– Aganju
Dec 17 '18 at 19:04















@Aganju Sqr is a VBA function

– davidmneedham
Dec 17 '18 at 20:42





@Aganju Sqr is a VBA function

– davidmneedham
Dec 17 '18 at 20:42













Also there will be a runtime error if x_ < k_

– trapper
Dec 19 '18 at 4:02





Also there will be a runtime error if x_ < k_

– trapper
Dec 19 '18 at 4:02










1 Answer
1






active

oldest

votes


















5














You need to add spaces before and after an operator, otherwise Excel cannot interpret it. So, e.g. instead of x_^3 use x_ ^ 3 etc.



You may also want to drop the _ from the variable/parameter names. It is very unusual notation and may lead to confusion when you break long commands into several rows with the _ sign.






share|improve this answer



















  • 1





    Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

    – BruceWayne
    Dec 17 '18 at 18:52











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385327%2fvery-simple-vba-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














You need to add spaces before and after an operator, otherwise Excel cannot interpret it. So, e.g. instead of x_^3 use x_ ^ 3 etc.



You may also want to drop the _ from the variable/parameter names. It is very unusual notation and may lead to confusion when you break long commands into several rows with the _ sign.






share|improve this answer



















  • 1





    Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

    – BruceWayne
    Dec 17 '18 at 18:52
















5














You need to add spaces before and after an operator, otherwise Excel cannot interpret it. So, e.g. instead of x_^3 use x_ ^ 3 etc.



You may also want to drop the _ from the variable/parameter names. It is very unusual notation and may lead to confusion when you break long commands into several rows with the _ sign.






share|improve this answer



















  • 1





    Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

    – BruceWayne
    Dec 17 '18 at 18:52














5












5








5







You need to add spaces before and after an operator, otherwise Excel cannot interpret it. So, e.g. instead of x_^3 use x_ ^ 3 etc.



You may also want to drop the _ from the variable/parameter names. It is very unusual notation and may lead to confusion when you break long commands into several rows with the _ sign.






share|improve this answer













You need to add spaces before and after an operator, otherwise Excel cannot interpret it. So, e.g. instead of x_^3 use x_ ^ 3 etc.



You may also want to drop the _ from the variable/parameter names. It is very unusual notation and may lead to confusion when you break long commands into several rows with the _ sign.







share|improve this answer












share|improve this answer



share|improve this answer










answered Dec 17 '18 at 18:49









teylynteylyn

17k22539




17k22539








  • 1





    Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

    – BruceWayne
    Dec 17 '18 at 18:52














  • 1





    Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

    – BruceWayne
    Dec 17 '18 at 18:52








1




1





Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

– BruceWayne
Dec 17 '18 at 18:52





Agreed on the note about the _ as the end of the variable name. It took me a little longer than usual to just understand that's a name, not a line break or something else.

– BruceWayne
Dec 17 '18 at 18:52


















draft saved

draft discarded




















































Thanks for contributing an answer to Super User!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385327%2fvery-simple-vba-error%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Список кардиналов, возведённых папой римским Каликстом III

Deduzione

Mysql.sock missing - “Can't connect to local MySQL server through socket”