none
HELP RRS feed

  • Question

  • Hello,

    i am Dario and i am very new at VBA. i am just 12 so i  am pretty basic and i am trying to make this code work.

    Private Sub CommandButton3_Click()

    Dim score As Integer, ans As String
    score = Range("A1").Value

    If score > 92 Then
        ans = "a"
    If score 82:91 Then
        ans = "b"
    Else
        ans = "c"
    End If

    Range("B1").Value = ans
    End Sub

    every time i make it work it highlights number 82 and sais:"expected Then or Go To".

    Thanks

    P.S. How do you become a PRO at this?

    Sunday, August 3, 2014 4:44 AM

Answers

  • 1. HELP is not a question. The subject of your post should be a question for a question post regarding what the body of your post further describes. Then if your question is answered and you propose the post that answered your question as the answer other people searching for an answer to a similar question can see the question in your subject line, see the thread was answered and review the thread. People don't search for HELP as that means nothing. So perhaps you could edit your post and alter HELP to an actual question and leave the word HELP out of it. When you post a question in any of these forums it's obvious you want HELP or you would not have posted a question.

    How to Use this Forum & FAQ (Read Before Making Your First Thread)

    2. I would recommend you use the MSDN Library search engine to search for information when necessary. It reflects within it all information that Microsoft has available for developers. Including information on VBA. I don't know VBA and have never used it as I don't have any Microsoft Office products installed on my system. However it's late at night where I live (12:47 A.M.) and most people who know VBA from what I've seen usually provide answers for that between about 6:30 A.M. my time and 8:00 P.M. my time. Not to say you will not receive an answer possibly outside of that time period.

    3. You can use the MSDN Library search engine to get results on VBA. I performed a search and the results are at the below link.

    MSDN Library search engine results for "VBA MSDN"

    4. To display code in a post being created or edited (open) at the top of the post is a toolbar. There's  a square button to the right of the letters HTML that is used to insert a code block wherever your caret position was in your post when you click on that button. Select the language to use, copy and paste your code into the square, preview and insert your code.

    5. Are you using Visual Basic .Net or are you using a macro in an office product? Because the code you show in your post does not look like VB.Net  or a mix of VB.Net with VBA specifically. It looks more to me like a VBA Macro being created for use in a Microsoft Office product like Excel perhaps.

    If you're using VB.Net to automate an office application then this is the correct forum for your question I would guess. However if you are creating a macro for an office application then the correct forum to post your question in would be the Visual Basic for Applications (VBA) forum.

    6. To become a PRO at anything depends on the persons abilities. Some people are slower than others at learning, etc. However someone who is a PRO at anything means someone knows mostly everything about something and is fully conversant with whatever that something is to the point that nothing with whatever that something is is beyond their knowledge of said something or comfort level of doing anything with said something. So a lot of time and effort is required to become a PRO at anything.

    But I also believe a true pro has the ability to provide an amateur or novice with an idea representing something the pro knows about something in such a way as the amateur or novice can receive an understanding of whatever the pro is describing at a level the amateur or novice have the ability to acquire the idea. Unless the amateur or novice are incapable or clueless along those lines.

    Of course this paragraph is just my opinion.

    7. Good luck in your efforts.

    And please reply if you are using VB.Net to automate an office application such as Excel or if you are actually writing a macro to use with an office product such as Excel. So people will know whether to respond to you or perhaps a Moderator, if they see this thread, could move this thread to a more appropriate Forum which they have the ability to do.

    But if I was you and you determine that the VBA forum is the correct forum for you then I would post a new question in that forum if I was you in order to get a response much sooner.


    La vida loca




    Sunday, August 3, 2014 7:15 AM
  • Also you may want to review links within this link on the left side of it.

    Welcome to the Visual Basic for Applications language reference for Office 2013

    And links on the left side of this link which is from a link on the left side of the above link.

    Visual Basic conceptual topics


    La vida loca


    Sunday, August 3, 2014 9:36 AM

All replies

  • 1. HELP is not a question. The subject of your post should be a question for a question post regarding what the body of your post further describes. Then if your question is answered and you propose the post that answered your question as the answer other people searching for an answer to a similar question can see the question in your subject line, see the thread was answered and review the thread. People don't search for HELP as that means nothing. So perhaps you could edit your post and alter HELP to an actual question and leave the word HELP out of it. When you post a question in any of these forums it's obvious you want HELP or you would not have posted a question.

    How to Use this Forum & FAQ (Read Before Making Your First Thread)

    2. I would recommend you use the MSDN Library search engine to search for information when necessary. It reflects within it all information that Microsoft has available for developers. Including information on VBA. I don't know VBA and have never used it as I don't have any Microsoft Office products installed on my system. However it's late at night where I live (12:47 A.M.) and most people who know VBA from what I've seen usually provide answers for that between about 6:30 A.M. my time and 8:00 P.M. my time. Not to say you will not receive an answer possibly outside of that time period.

    3. You can use the MSDN Library search engine to get results on VBA. I performed a search and the results are at the below link.

    MSDN Library search engine results for "VBA MSDN"

    4. To display code in a post being created or edited (open) at the top of the post is a toolbar. There's  a square button to the right of the letters HTML that is used to insert a code block wherever your caret position was in your post when you click on that button. Select the language to use, copy and paste your code into the square, preview and insert your code.

    5. Are you using Visual Basic .Net or are you using a macro in an office product? Because the code you show in your post does not look like VB.Net  or a mix of VB.Net with VBA specifically. It looks more to me like a VBA Macro being created for use in a Microsoft Office product like Excel perhaps.

    If you're using VB.Net to automate an office application then this is the correct forum for your question I would guess. However if you are creating a macro for an office application then the correct forum to post your question in would be the Visual Basic for Applications (VBA) forum.

    6. To become a PRO at anything depends on the persons abilities. Some people are slower than others at learning, etc. However someone who is a PRO at anything means someone knows mostly everything about something and is fully conversant with whatever that something is to the point that nothing with whatever that something is is beyond their knowledge of said something or comfort level of doing anything with said something. So a lot of time and effort is required to become a PRO at anything.

    But I also believe a true pro has the ability to provide an amateur or novice with an idea representing something the pro knows about something in such a way as the amateur or novice can receive an understanding of whatever the pro is describing at a level the amateur or novice have the ability to acquire the idea. Unless the amateur or novice are incapable or clueless along those lines.

    Of course this paragraph is just my opinion.

    7. Good luck in your efforts.

    And please reply if you are using VB.Net to automate an office application such as Excel or if you are actually writing a macro to use with an office product such as Excel. So people will know whether to respond to you or perhaps a Moderator, if they see this thread, could move this thread to a more appropriate Forum which they have the ability to do.

    But if I was you and you determine that the VBA forum is the correct forum for you then I would post a new question in that forum if I was you in order to get a response much sooner.


    La vida loca




    Sunday, August 3, 2014 7:15 AM
  • If score 82:91 Then

    That code is not valid. Perhaps you mean  

        If score >= 82 And score <= 91 Then

    Questions relating to VBA should be asked here:

    Visual Basic for Applications  (VBA)


    • Edited by Acamar Sunday, August 3, 2014 8:33 AM sp
    Sunday, August 3, 2014 8:32 AM
  • Also you may want to review links within this link on the left side of it.

    Welcome to the Visual Basic for Applications language reference for Office 2013

    And links on the left side of this link which is from a link on the left side of the above link.

    Visual Basic conceptual topics


    La vida loca


    Sunday, August 3, 2014 9:36 AM