VBA display message box, pick yes or no

Jack_Mason

New Member
Joined
Nov 19, 2020
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
I have a load of text data which I need to read through to confirm if its relevant or not. I want to display the text from each cell in column D in a message box and then click ‘yes’ or ‘no’ depending on its relevancy and then move onto the next cell down, when i click yes or no i want it to write yes or no in the column next to it so i can filter through this at a later date. Please, can anyone help me with this code?
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Welcome to the Board!

Here is a little example that I think will show you how to do what you want:
VBA Code:
Sub MyMacro()

    Dim response
   
    response = MsgBox("Select Yes or No", vbYesNo)
   
    If response = vbYes Then
        Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = "Yes"
    Else
        Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = "No"
    End If
   
End Sub
 
Upvote 0
Hi,
try following & see if does what you want


VBA Code:
Sub YesNo()
    Dim rng As Range, cell As Range
    Dim Response As VbMsgBoxResult
    
    Set rng = Range(Range("D1"), Range("D" & Rows.Count).End(xlUp))
    
    For Each cell In rng.Cells
       'optional - highlights each cell
        cell.Select
        Response = MsgBox(cell.Text & Chr(10) & "Relevant?", 35, "Relevance")
        If Response = vbCancel Then Exit Sub
        
        cell.Offset(, 1).Value = IIf(Response = vbYes, "Yes", "No")
        
    Next cell

End Sub

Dave
 
Upvote 0
Solution
Hi,
try following & see if does what you want


VBA Code:
Sub YesNo()
    Dim rng As Range, cell As Range
    Dim Response As VbMsgBoxResult
   
    Set rng = Range(Range("D1"), Range("D" & Rows.Count).End(xlUp))
   
    For Each cell In rng.Cells
       'optional - highlights each cell
        cell.Select
        Response = MsgBox(cell.Text & Chr(10) & "Relevant?", 35, "Relevance")
        If Response = vbCancel Then Exit Sub
       
        cell.Offset(, 1).Value = IIf(Response = vbYes, "Yes", "No")
       
    Next cell

End Sub

Dave
This is perfect! Thank you
 
Upvote 0
Welcome to the Board!

Here is a little example that I think will show you how to do what you want:
VBA Code:
Sub MyMacro()

    Dim response
  
    response = MsgBox("Select Yes or No", vbYesNo)
  
    If response = vbYes Then
        Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = "Yes"
    Else
        Cells(Rows.Count, "D").End(xlUp).Offset(1, 0) = "No"
    End If
  
End Sub
Thank you
 
Upvote 0
You are welcome.

Glad we could help!
 
Upvote 0

Forum statistics

Threads
1,223,888
Messages
6,175,217
Members
452,619
Latest member
Shiv1198

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top