+ Reply to Thread
Results 1 to 5 of 5

New to VBA

  1. #1
    Registered User
    Join Date
    02-14-2019
    Location
    Texas
    MS-Off Ver
    MO 2016
    Posts
    11

    New to VBA

    Greeting Everyone,
    I been scratching my head in order to get this macro to work the way i want but have not been able to do so, so i am requesting help from the forum.
    What i want the code to do is to show a msgbox("Top plate must be change now" if cell I7 = 1 and to show the 2nd msgbox if cell I7=0.
    And what is currently doing is showing both msgbox on after the other.
    Also the sub is call manually with a button.
    Any help is very much appreciated.

    Thanks


    Sub Tooling()
    Result = MsgBox("Top Plate Must be change now", vbOKOnly + vbCritical)
    Counter = Range("i7")

    If Counter = 1 Then
    MsgBox "Top Plate Must be change now", vbOKOnly + vbCritical
    Result = vbOK
    Sheets("Tooling").Protect "password", True, True

    ElseIf Counter = 0 Then
    MsgBox "Click Check Tooling button at the end of shift", vbOKOnly + vbInformation

    End If

    End Sub

  2. #2
    Forum Expert Roel Jongman's Avatar
    Join Date
    03-28-2015
    Location
    Netherlands
    MS-Off Ver
    Office 365
    Posts
    1,483

    Re: New to VBA

    Hi VRSMeza

    welcome.. you have 3 codelines for msgboxes and the first one excecutes always regardless of the value of I7 that test comes later. as it is the first line of code..

    the following code should do what you expect
    Please Login or Register  to view this content.
    _____________
    small request, whenever you post code to the forum please always use code tags (#-icon) it is one of the forumrules to do so.

  3. #3
    Registered User
    Join Date
    02-14-2019
    Location
    Texas
    MS-Off Ver
    MO 2016
    Posts
    11

    Re: New to VBA

    That did the job thanks a lot.
    Will do the code tags for future posts. Now I will try to figure out how to mark this as SOLVED.

    Thank You Roel Jongman

  4. #4
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,873

    Re: New to VBA

    VRSMeza

    Please take a few minutes to read all the forum rules. Particularly pay attention to the ones about Thread Titles and Code Tags. I have marked this solved for you today.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  5. #5
    Registered User
    Join Date
    02-14-2019
    Location
    Texas
    MS-Off Ver
    MO 2016
    Posts
    11

    Re: New to VBA

    Will do.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1