+ Reply to Thread
Results 1 to 5 of 5

How to use before close function with multiple condition are met

  1. #1
    Registered User
    Join Date
    10-24-2017
    Location
    islamabad pakistan
    MS-Off Ver
    office 16
    Posts
    2

    How to use before close function with multiple condition are met

    Hi,
    I am new to programming. I am trying to write a code for excel sheet form, where multiple individuals have to give their feedback, and my target is creating a sheet in which if one individual respond to certain query as “No” then he should mention his reasons in the corresponding Colum before closing the sheet.
    A message box should appear to prompt him that he has to fill the corresponding required field

    For example:
    If someone selects “No” from the drop-down selection and he does not put a reason for this then he should get a prompt massage and sheet shouldn’t be close until he fills the reason for that.
    This is here I have reached so for. it will be appreciated if someone could helpImage.jpg


    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    If Cells(8, 4).Value = "" Then
    MsgBox "Please fill the Remarks "
    Cancel = True
    End If

    End Sub
    Private Sub Workbook_Open()
    End Sub

  2. #2
    Valued Forum Contributor
    Join Date
    12-01-2016
    Location
    Planet Earth
    MS-Off Ver
    95 - 2016
    Posts
    343

    Re: How to use before close function with multiple condition are met

    Try this

    Please Login or Register  to view this content.

  3. #3
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: How to use before close function with multiple condition are met

    This macro will force entry of a reason if "No" is chosen. Copy and paste this macro into the worksheet code module. Do the following: right click the tab for your sheet and click 'View Code'. Paste the macro into the empty code window that opens up. Close the code window to return to your sheet. Choose Yes or No in column C.
    Please Login or Register  to view this content.
    You can say "THANK YOU" for help received by clicking the Star symbol at the bottom left of the helper's post.
    Practice makes perfect. I'm very far from perfect so I'm still practising.

  4. #4
    Registered User
    Join Date
    10-24-2017
    Location
    islamabad pakistan
    MS-Off Ver
    office 16
    Posts
    2

    Re: How to use before close function with multiple condition are met

    Thanks!

    It really helped. I am thankful

  5. #5
    Forum Expert Mumps1's Avatar
    Join Date
    10-10-2012
    Location
    Toronto, Canada
    MS-Off Ver
    Excel 2010, 365
    Posts
    8,026

    Re: How to use before close function with multiple condition are met

    You are very welcome.

+ 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. multiple if function and condition
    By praneem in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-12-2017, 10:24 AM
  2. [SOLVED] Userform Close (x) Check condition before close
    By rr1050 in forum Excel Programming / VBA / Macros
    Replies: 10
    Last Post: 07-07-2016, 06:55 AM
  3. [SOLVED] Multiple condition IF function - I'm stuck!
    By quickheart in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-13-2015, 05:50 AM
  4. How to use IF, AND function for multiple condition
    By Akatecho in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-29-2015, 05:05 AM
  5. Multiple condition lookup for Index function
    By cheal2 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 04-17-2013, 09:13 AM
  6. Replies: 9
    Last Post: 02-20-2012, 07:46 PM
  7. How to use MAX function with multiple condition
    By MAHMUZ in forum Excel General
    Replies: 7
    Last Post: 10-25-2010, 03:30 AM

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