PDA

View Full Version : Solved: Question Box on Flowchart



KateMaz
06-25-2013, 05:50 AM
Hello!

I was wondering if someone could help me with my flowchart. I've written a code so far is like this;
Sub Auto_Open()
ActiveSheet.DrawingObjects.Visible = False
ActiveSheet.Shapes("Button 77").Visible = True
ActiveSheet.Shapes("Button 78").Visible = True
ActiveSheet.Shapes("Button 79").Visible = True
ActiveSheet.Shapes("Button 80").Visible = True
End Sub

Sub Start()
ActiveSheet.Shapes("Button 77").Select
ActiveSheet.Shapes("AutoShape 2").Visible = True
End Sub

Sub Scroll()

If ActiveSheet.Shapes("AutoShape 14").Visible = True Then
ActiveSheet.Shapes("Line 15").Visible = True
ActiveSheet.Shapes("AutoShape 16").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 12").Visible = True Then
ActiveSheet.Shapes("Line 13").Visible = True
ActiveSheet.Shapes("AutoShape 14").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 10").Visible = True Then
ActiveSheet.Shapes("Line 11").Visible = True
ActiveSheet.Shapes("AutoShape 12").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 8").Visible = True Then
ActiveSheet.Shapes("Line 9").Visible = True
ActiveSheet.Shapes("AutoShape 10").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 5").Visible = True Then
ActiveSheet.Shapes("Line 6").Visible = True
ActiveSheet.Shapes("AutoShape 8").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 2").Visible = True Then
ActiveSheet.Shapes("Line 4").Visible = True
ActiveSheet.Shapes("AutoShape 5").Visible = True
End If

End Sub

Sub Reset()
Call Auto_Open
iCounter = 0
End
End Sub


Which means that you click start, the first process box comes up, you then click next which shows the next process box, and you continue to click next until you come to "Autoshape 16" which is a question box, I need the code to continue like the above but would like a msgbox to pop up with the question and if you click "yes" then it reveals "Line 19" and "Autoshape 21" and if you click no then it reveals "Line 17" and "Autoshape 18".

After this msgbox I then need to continue with the "Next" button until you reach the end of the flowchart.

Is this possible at all?

Thanks in advance!

Kate

afzalw
06-30-2013, 02:51 PM
Try using the code from here:
http://www.excely.com/excel-vba/using-message-box.shtml

KateMaz
07-01-2013, 02:21 AM
Thanks afzalw

I have tried entering this code;


Sub Auto_Open()
ActiveSheet.DrawingObjects.Visible = False
ActiveSheet.Shapes("Button 77").Visible = True
ActiveSheet.Shapes("Button 78").Visible = True
ActiveSheet.Shapes("Button 79").Visible = True
ActiveSheet.Shapes("Button 80").Visible = True
End Sub

Sub Start()
ActiveSheet.Shapes("Button 77").Select
ActiveSheet.Shapes("AutoShape 2").Visible = True
End Sub

Sub Scroll()

If ActiveSheet.Shapes("AutoShape 16").Visible = True Then
strprompt = "Do they improve their offer?"
strtitle = "Decision"
iret = MsgBox(strprompt, vbYesNo, strtitle)
End If
If iret = vbYes Then
ActiveSheet.Shapes("AutoShape 21").Visible = True
ActiveSheet.Shapes("Line 19").Visible = True
Else
ActiveSheet.Shapes("Line 17").Visible = True
ActiveSheet.Shapes("AutoShape 18").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 14").Visible = True Then
ActiveSheet.Shapes("Line 15").Visible = True
ActiveSheet.Shapes("AutoShape 16").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 12").Visible = True Then
ActiveSheet.Shapes("Line 13").Visible = True
ActiveSheet.Shapes("AutoShape 14").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 10").Visible = True Then
ActiveSheet.Shapes("Line 11").Visible = True
ActiveSheet.Shapes("AutoShape 12").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 8").Visible = True Then
ActiveSheet.Shapes("Line 9").Visible = True
ActiveSheet.Shapes("AutoShape 10").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 5").Visible = True Then
ActiveSheet.Shapes("Line 6").Visible = True
ActiveSheet.Shapes("AutoShape 8").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 2").Visible = True Then
ActiveSheet.Shapes("Line 4").Visible = True
ActiveSheet.Shapes("AutoShape 5").Visible = True
End If

End Sub

Sub Reset()
Call Auto_Open
iCounter = 0
End
End Sub


But it shows the "No" answer with the first click on the Next button. It doesn't wait until the Question is asked.

But thanks anyway! :-)

KateMaz
07-01-2013, 07:43 AM
Hi, I've managed to solve this with the following code;

Sub Auto_Open()
ActiveSheet.DrawingObjects.Visible = False
ActiveSheet.Shapes("Button 77").Visible = True
ActiveSheet.Shapes("Button 78").Visible = True
ActiveSheet.Shapes("Button 79").Visible = True
ActiveSheet.Shapes("Button 80").Visible = True
End Sub

Sub Start()
ActiveSheet.Shapes("Button 77").Select
ActiveSheet.Shapes("AutoShape 2").Visible = True
End Sub

Sub Scroll()

If ActiveSheet.Shapes("AutoShape 16").Visible = True Then
iret = MsgBox("Do they improve their offer?", vbYesNo, "Decision")
End If
If iret = vbYes Then
ActiveSheet.Shapes("Line 19").Visible = True
ActiveSheet.Shapes("AutoShape 21").Visible = True
ElseIf iret = vbNo Then
ActiveSheet.Shapes("Line 17").Visible = True
ActiveSheet.Shapes("AutoShape 18").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 14").Visible = True Then
ActiveSheet.Shapes("Line 15").Visible = True
ActiveSheet.Shapes("AutoShape 16").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 12").Visible = True Then
ActiveSheet.Shapes("Line 13").Visible = True
ActiveSheet.Shapes("AutoShape 14").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 10").Visible = True Then
ActiveSheet.Shapes("Line 11").Visible = True
ActiveSheet.Shapes("AutoShape 12").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 8").Visible = True Then
ActiveSheet.Shapes("Line 9").Visible = True
ActiveSheet.Shapes("AutoShape 10").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 5").Visible = True Then
ActiveSheet.Shapes("Line 6").Visible = True
ActiveSheet.Shapes("AutoShape 8").Visible = True
End If

If ActiveSheet.Shapes("AutoShape 2").Visible = True Then
ActiveSheet.Shapes("Line 4").Visible = True
ActiveSheet.Shapes("AutoShape 5").Visible = True
End If

End Sub

Sub Reset()
Call Auto_Open
iCounter = 0
End
End Sub