VB Yes No Problem

ccalkins

New Member
Joined
Jul 13, 2016
Messages
13
Office Version
  1. 365
Platform
  1. MacOS
I am very novice with VBA and have adapted what I would like to do from code on this forum and the internet. It all works except for if you click No on the "GO" part. I cannot figure out what is happening and would appreciate any help.
Craig

Sub CorpsChiefUpdate()
Dim GO As Integer
Dim CorpsChief As Integer

GO = MsgBox("Is the Corps Chief still a General Officer?", vbYesNo + vbQuestion, "Corps Chief")
If GO = vbYes Then

CorpsChief = MsgBox("Is the Corps Chief still: " & Sheets("Federal Holidays").Range("I1").Value, vbYesNo + vbQuestion, "Corps Chief")
If CorpsChief = vbYes Then

Else
If GO = vbNo Then
Sheets("Federal Holidays").Range("I1:I3").Clear

Else
If CorpsChief = vbNo Then
'Update Name
Dim Name As String
Name = InputBox("New Corps Chief's Name", "Corps Chief", "Rank Last Name")
Sheets("Federal Holidays").Range("I1").Value = Name
'Update DOB
Dim DOB As String
DOB = InputBox("New Corps Chief's DOB", "Corps Chief", "MM/DD/YYYY")
Sheets("Federal Holidays").Range("I2").Value = DOB
'Update Email Address
Dim Email As String
Email = InputBox("New Corps Chief's Email Address", "Corps Chief", "mail.mil")
Sheets("Federal Holidays").Range("I3").Value = Email

End If
End If
End If
End If
End Sub
 

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
I think it's a logic thing... Your code will only execute the entire code if you select Go=vbYes

Adding Code tags so your code is more readable.
Code:
Sub CorpsChiefUpdate()
Dim GO As Integer
Dim CorpsChief As Integer


GO = MsgBox("Is the Corps Chief still a General Officer?", vbYesNo + vbQuestion, "Corps Chief")
If GO = vbYes Then
    CorpsChief = MsgBox("Is the Corps Chief still: " & Sheets("Federal Holidays").Range("I1").Value, vbYesNo + vbQuestion, "Corps Chief")
    If CorpsChief = vbYes Then
    
    Else
        If GO = vbNo Then
            Sheets("Federal Holidays").Range("I1:I3").Clear
        Else
            If CorpsChief = vbNo Then
                'Update Name
                Dim Name As String
                Name = InputBox("New Corps Chief's Name", "Corps Chief", "Rank Last Name")
                Sheets("Federal Holidays").Range("I1").Value = Name
                'Update DOB
                Dim DOB As String
                DOB = InputBox("New Corps Chief's DOB", "Corps Chief", "MM/DD/YYYY")
                Sheets("Federal Holidays").Range("I2").Value = DOB
                'Update Email Address
                Dim Email As String
                Email = InputBox("New Corps Chief's Email Address", "Corps Chief", "mail.mil")
                Sheets("Federal Holidays").Range("I3").Value = Email
            End If
        End If
    End If
End If
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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