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

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
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,223,893
Messages
6,175,246
Members
452,623
Latest member
cliftonhandyman

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