+ Reply to Thread
Results 1 to 5 of 5

Skip MsgBox if found error

Hybrid View

  1. #1
    Valued Forum Contributor
    Join Date
    03-28-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    702

    Skip MsgBox if found error

    Hi,

    Using Global Variable declaration and 2 sub functions, I am able to skip MsgBox if the call Macro name has triggered error message. However when call macro name has been transferred to UserForm platform, it will be no longer applicable due to variable (FindWhom) in UserForm has not recognized in the Module (Main Sub). The main purpose of using UserForm is to create progress indicator

    Is there any alternative method? Here is a simple description of my problem..
    Option Explicit
    Dim FindWhom As Integer
    
    Sub openFile()
    
      Call PopulateData
      If FindWhom <> 1 Then MsgBox "Data sucessfully updated"
    End Sub
    
    
    
    
    Sub PopulateData()
    Dim i As Integer, j As Integer
    
    If i <> j Then GoTo GetNext
    
        MsgBox "Found error due to data have not been added"
        FindWhom = 1
        Exit Sub
    
    GetNext:
    End Sub
    Last edited by Faridwahidi; 11-10-2015 at 01:07 PM.
    1. Thank those who have helped you by clicking the Star * below the post.
    2. Please mark your post [SOLVED] if it has been answered satisfactorily.

    Sincerely,
    Farid

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Skip MsgBox if found error

    Hi,

    Have you tried declaring it as a Public variable?
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Valued Forum Contributor
    Join Date
    03-28-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    702

    Re: Skip MsgBox if found error

    Hi Richard,

    I have tested and it working fine

    In a proper manner, public variable supposed to be declared in the Main Sub or UserForm or both?

    or if without using this method, any best alternative method to skip MsgBox for such problem
    Last edited by Faridwahidi; 11-10-2015 at 01:20 PM.

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Skip MsgBox if found error

    Hi,

    By its very nature a Public variable can't be displayed in a procedure it needs to be placed at the Module level.
    You can also choose to pass a value when you call another procedure and use that value in a variable that's declared in the second procedure.

    i.e.

    Call MyOtherProcedure("Yes")
    Sub MyOtherProcedure(myVariable as String)
       Msgbox myVariable ' will result in "Yes"
    
    End Sub
    If you're interested in the full War and Peace story on the scope of variables then see here...https://support.microsoft.com/en-gb/kb/141693

  5. #5
    Valued Forum Contributor
    Join Date
    03-28-2014
    Location
    Kuala Lumpur, Malaysia
    MS-Off Ver
    Excel 2016
    Posts
    702

    Re: Skip MsgBox if found error

    Hi,

    Thank you sir.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. VBA - If value not found, skip part of macro.
    By crayhons in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-13-2013, 08:31 AM
  2. Skip a 'file not found' dialogue in a loop
    By dicenn in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-02-2013, 01:08 PM
  3. How to skip filter action if particular value is not found in record
    By shaikh_javed246 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-31-2012, 02:15 PM
  4. [SOLVED] Msgbox to present values not found
    By pedrofogao21 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-26-2012, 03:10 PM
  5. Searching for a value but skip the first found value.
    By george1982 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 06-14-2009, 09:35 AM
  6. Msgbox until a specific string is found.
    By excelkeechak in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-22-2009, 09:43 PM
  7. hlookup to skip past first found 'lookup_value'
    By Ben Morton in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 10-23-2008, 08:57 AM
  8. skip to next cell if no value is found
    By AirCav in forum Excel General
    Replies: 0
    Last Post: 02-09-2006, 01:50 PM

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