+ Reply to Thread
Results 1 to 6 of 6

Repeat Message box routine with IF condition and condnl formatting

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Repeat Message box routine with IF condition and condnl formatting

    Hi all,

    I have a sample sheet which explains everything.

    Two issues:
    I want message box routine to repeat until valid value from range 'Reason' or 'NA' is entered.
    Basic code:
    Private Sub Worksheet_Change(ByVal Target As Range)
    If ThisWorkbook.Sheets(1).Range("G26").Value = "1" Then
    MsgBox " Input Reasons for Delay. If On Time, Please enter 'NA'."
    'need help here to add - repeat messagebox routine until valid text from Range "Reason" and "NA" is entered
    End If
    End Sub
    Second issue
    If value in G26 is equal to 1, then cell C27 must get drop down menu options from Range 'Reason' and if value is zero then it simply indicates NA

    Any help please
    Kind regards
    Attached Files Attached Files

  2. #2
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Repeat Message box routine with IF condition and condnl formatting

    Remove your Current Sheet change event code and no need of G26 cell since I covered it in the below code

    To Add Excel VBA Code to a Workbook / This Workbook Module
    1. Copy the code that you want to use
    2. Select the workbook in which you want to store the code
    3. Hold the Alt key, and press the F11 key, to open the Visual Basic Editor
    4. In the Project Explorer, find your workbook, and open the list of Microsoft Excel Objects
    5. Right-click on the ThisWorkbook object, and choose View Code
    6. Where the cursor is flashing, choose Edit | Paste

    Private Sub Workbook_SheetCalculate(ByVal Sh As Object)
    
    If UCase(Sh.Name) = "SHEET1" Then
        With Range("C26")
            If .Value = "Delayed" Then
                MsgBox " Input Reasons for Delay. If On Time, Please enter 'NA'."
                .Offset(1).Select
                ActiveCell.ClearContents
                With Selection.Validation
                    .Delete
                    .Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Operator:= _
                    xlBetween, Formula1:="=Reason"
                    .InCellDropdown = True
                    .ShowInput = True
                    .ShowError = True
                End With
            Else
                With .Offset(1)
                    .Value = "NA"
                    .Validation.Delete
                End With
            End If
        End With
    End If
        
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  3. #3
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Repeat Message box routine with IF condition and condnl formatting

    Hi Sixthsense,
    Nice to see you again. You have kindly helped me many times in the past.
    Again Very Kind of you to help me with your prompt reply.
    I have followed the steps, however I still may have not correctly understood it.
    I have attached the new sample.
    Please have a look.
    Thanks again.
    Kind regards
    Attached Files Attached Files

  4. #4
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Repeat Message box routine with IF condition and condnl formatting

    Go through the attached file and place the cursor in H10 cell and press F2 and enter and check
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-19-2013
    Location
    UK
    MS-Off Ver
    Excel 2019
    Posts
    677

    Re: Repeat Message box routine with IF condition and condnl formatting

    Hi SixthSense,
    I found my mistakes.
    It works great .
    What a solution. Perfect.
    Really a great & very clever help from you.

    Many thanks
    I have certainly clicked * to express my gratitude.
    Kind regards
    KK1234

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Repeat Message box routine with IF condition and condnl formatting

    Glad it helps you and thanks for the feedback and rep

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED. Thanks.

+ 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. [SOLVED] Run routine on entering a txt box with condition/if statement
    By johnny_p in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-18-2013, 08:30 AM
  2. Slight modification to formatting sub-routine
    By pglufkin in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2013, 07:06 PM
  3. Slight modification to formatting sub-routine
    By pglufkin in forum Excel General
    Replies: 0
    Last Post: 11-07-2013, 02:44 PM
  4. Macro for repeat functions with if condition
    By mkanagaraj in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 10-23-2012, 02:08 AM
  5. Sum until a condition is met and repeat for a range
    By natattack in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 10-13-2012, 06:30 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