TheWaterDog
New Member
- Joined
- May 24, 2022
- Messages
- 8
- Office Version
- 365
- Platform
- Windows
Apologies if this thread exists - I've searched and not found a solution in any of the threads.
Can anyone tell me why my vbNo answer runs the same as vbYes - what have I missed? No error - just runs the sub the same as vbYes; I've tried six million ways of ending sub and nothing works.
Section in RED below
Explanation of sub:
Shapes on sheet "Image Map" are named as Ref (i.e NH.02.34)
Ref is inputted in Cell R2 on shape click
Cells R3:X12 use R2 to index/match data from another sheet (Schedule Data)
MsgBox displays data from Cells R3:X12
User Clicks Yes - Cells R3:X12 exported and saved as PDF
MsgBox display success with PDF name
But...
User Clicks No
...and sub does not exit...runs the same as Yes click
Can anyone tell me why my vbNo answer runs the same as vbYes - what have I missed? No error - just runs the sub the same as vbYes; I've tried six million ways of ending sub and nothing works.
Section in RED below
Explanation of sub:
Shapes on sheet "Image Map" are named as Ref (i.e NH.02.34)
Ref is inputted in Cell R2 on shape click
Cells R3:X12 use R2 to index/match data from another sheet (Schedule Data)
MsgBox displays data from Cells R3:X12
User Clicks Yes - Cells R3:X12 exported and saved as PDF
MsgBox display success with PDF name
But...
User Clicks No
...and sub does not exit...runs the same as Yes click
Rich (BB code):
Sub Fetch_NH_02_34()
'Shape Located in Elevation (North 1) 0207 - Top Row
'Click to input Shape Reference into Cell R2 to allow index/match function in cells R3 to Z12 to call data from Schedule Sheet
ActiveSheet.Shapes.Range(Array("NH.02.34")).Select
Range("R2").Select
ActiveCell.FormulaR1C1 = "NH.02.34"
'Keep the sheet from scrolling away from location
Range("A20").Select
'Open Message Box and display data in cells R2 to Z12
MsgBox "WINDOW " & Worksheets("Image Map").Range("r2").Value & vbNewLine & Worksheets("Image Map").Range("t3").Value & "mm width | " & Worksheets("Image Map").Range("u3").Value & "mm height" & vbNewLine & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r3").Value & vbNewLine & Worksheets("Image Map").Range("s3").Value & " (" & Worksheets("Image Map").Range("w3").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x3").Value & " - " & Worksheets("Image Map").Range("y3").Value & " (" & Worksheets("Image Map").Range("z3").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r4").Value & vbNewLine & Worksheets("Image Map").Range("s4").Value & " (" & Worksheets("Image Map").Range("w4").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x4").Value & " - " & Worksheets("Image Map").Range("y4").Value & " (" & Worksheets("Image Map").Range("z4").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r5").Value & vbNewLine & Worksheets("Image Map").Range("s5").Value & " (" & Worksheets("Image Map").Range("w5").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x5").Value & " - " & Worksheets("Image Map").Range("y5").Value & " (" & Worksheets("Image Map").Range("z5").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r6").Value & vbNewLine & Worksheets("Image Map").Range("s6").Value & " (" & Worksheets("Image Map").Range("w6").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x6").Value & " - " & Worksheets("Image Map").Range("y6").Value & " (" & Worksheets("Image Map").Range("z6").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r7").Value & vbNewLine & Worksheets("Image Map").Range("s7").Value & " (" & Worksheets("Image Map").Range("w7").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x7").Value & " - " & Worksheets("Image Map").Range("y7").Value & " (" & Worksheets("Image Map").Range("z7").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r8").Value & vbNewLine & Worksheets("Image Map").Range("s8").Value & " (" & Worksheets("Image Map").Range("w8").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x8").Value & " - " & Worksheets("Image Map").Range("y8").Value & " (" & Worksheets("Image Map").Range("z8").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r9").Value & vbNewLine & Worksheets("Image Map").Range("s9").Value & " (" & Worksheets("Image Map").Range("w9").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x9").Value & " - " & Worksheets("Image Map").Range("y9").Value & " (" & Worksheets("Image Map").Range("z9").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r10").Value & vbNewLine & Worksheets("Image Map").Range("s10").Value & " (" & Worksheets("Image Map").Range("w10").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x10").Value & " - " & Worksheets("Image Map").Range("y10").Value & " (" & Worksheets("Image Map").Range("z10").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r11").Value & vbNewLine & Worksheets("Image Map").Range("s11").Value & " (" & Worksheets("Image Map").Range("w11").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x11").Value & " - " & Worksheets("Image Map").Range("y11").Value & " (" & Worksheets("Image Map").Range("z11").Value & ")" & vbNewLine & vbNewLine _
& "A1 Schedule Ref: " & Worksheets("Image Map").Range("r12").Value & vbNewLine & Worksheets("Image Map").Range("s12").Value & " (" & Worksheets("Image Map").Range("w12").Value & ")" & vbNewLine & _
Worksheets("Image Map").Range("x12").Value & " - " & Worksheets("Image Map").Range("y12").Value & " (" & Worksheets("Image Map").Range("z12").Value & ")" & vbNewLine & vbNewLine _
& vbNewLine & "Tap 'YES' to create an index card for this data or 'NO' to exit.", vbYesNo
'User answers Yes
If vbYes Then
'Create PDF from Cells Q1 to AC12
'Save in Index Card Folder with filename as Shape Reference
ActiveSheet.Range("Q1:AC12").ExportAsFixedFormat Type:=0, _
filename:="C:\Users\FRC\Desktop\IE85\A1 Index Cards\" & ActiveSheet.Range("R2").Value & " - " & Format(Now(), "YYYY-MM-DD hhmm"), _
Quality:=0, IncludeDocProperties:=False, IgnorePrintAreas:=False, _
openafterpublish:=False
'Display confirmation of Save
MsgBox "Saved as " & Worksheets("Image Map").Range("r2").Value & " - " & Format(Now(), "YYYY-MM-DD hhmm")
End If
'User answers No or X
If vbNo Then
Exit Sub
End If
End Sub
Last edited by a moderator: