• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

User input populate field

ysherriff

Member
Hello,

I have a macro that a message box opens and the user selects "yes", or "no". If the entry is "no", i want it to populate the next empty cell in a column. How do i accomplish that?

For example in the image below, if a user selects "no", then i would like the macro check the adjacent column, in this case column e to see if it is blank. If it is, then populate the adjacent column d with "no".

So basically, everytime the user presses, "no", then it checks for the next empty cell.

I did a small example in the attached email. Thank you for your help

Code:
Sub CJR_Admits()
Dim YesOrNoAnswerToMessageBox As String, QuestionToMessageBox As String

    QuestionToMessageBox = "Did you have any CJR patient admissions this month?"

    YesOrNoAnswerToMessageBox = MsgBox(QuestionToMessageBox, vbYesNo, "CJR Admits or Not?")

    If YesOrNoAnswerToMessageBox = vbNo Then
         Range("D1") = "NO"
         MsgBox "Thank you for being compliant. Please close the log."
    Else
        MsgBox "Please proceed to enter data into the log"
    End If

End Sub

upload_2016-10-6_16-57-47.png
 
Can you please walk us through the use process

1. Run macro
2. If user answers Yes what happens, If No what happens
use cell references from the example
 
Back
Top