Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8921015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:25:37+00:00 2026-06-15T06:25:37+00:00

Good Morning. I am having trouble with a segment of code that has worked

  • 0

Good Morning. I am having trouble with a segment of code that has worked well in the past for me.

Private Sub Workbook_Open()

UserForm1.Show

End Sub

Stored in the UserForm

Private Sub CommandButton1_Click()

'   Verify All Fields
Msg = "Have you entered all Fields?"
Title = "TONU"
Config = vbYesNo + vbQuestion
Ans = MsgBox(Msg, Config, Title)
    If Ans = Yes Then GoTo nextstep:
    If Ans = No Then Exit Sub

nextstep:

'   Print Option
Msg1 = "Would you like to Print a hard copy?"
Title1 = "TONU"
Config1 = vbYesNo + vbQuestion
Ans1 = MsgBox(Msg1, Config1, Title1)
    If Ans1 = Yes Then UserForm1.Print
    If Ans1 = No Then Run Report


lastRow = Sheets("Sheet1").Cells(Rows.Count, "A").End(xlUp).Row + 1

MsgBox lastRow


End Sub       

The UserForm prints fine in my other project, but when a use this code in a new project it does not print?!?! Thoughts?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T06:25:38+00:00Added an answer on June 15, 2026 at 6:25 am

    “Yes” is not a valid VbMsgBoxResult. It should be vbYes or vbNo. In the first instance your code will just fall through to NextStep. In the second it will do nothing.

    To avoid this type of error use Option Explicit at the top of your modules. Then it will complain that Yes and No are undeclared variables.

    Better yet, check “Require Variable Declaration” in Tools>Options, to have Option Explicit automatically placed at the top of each module.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Good morning, I am having trouble with the following code <html> <head> <title>highlight date</title>
Good morning, I'm having a really annoying issue with Highcharts, such that the x-axis
Good morning to everybody, :) I have writen a code in C++ that reads
Good Morning Stack OverFlow enthusiasts. I have been having an issue that I am
Good morning. I'm having trouble with a UIImagePickerController not showing anything other than white.
Good morning. I've been having this issue for some days and have been lokking
Good morning all, I'm having a few problems with a method in my C#
Good morning, I am currently developing a java web application that exposes a web
Good morning gang. I have a jQuery Datepicker object that is prepoulated using a
Good morning. After having read the answer on a question about optimizing Excel Interop

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.