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 8467051
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T15:31:45+00:00 2026-06-10T15:31:45+00:00

Being self taught I have not learned everything there is to know about Excel

  • 0

Being self taught I have not learned everything there is to know about Excel VBA. Hell lets be honest, I know some basics, but not as much as I probably should, so this question although probably a generic basic question, probably should be known by someone who knows VBA, but in the case of I learn what I need to move forward… so I need an explanation.

When do you need to define a Sub or Function? Why do you need to define a Sub or Function? What is the purpose of defining a Sub or Function?

I only ask, because of this:

Option Explicit

Sub OpenOrderReportExport()

    Dim wsJL As Worksheet   'Jobs List
    Dim wsPOT As Worksheet  'PO Tracking
    Dim wsTNO As Worksheet  'Tel-Nexx OOR
    Dim wbBK2 As Workbook   'New Workbook
    Dim wsWS1 As Worksheet  'Sheet1
    Dim wsWS2 As Worksheet  'Sheet2
    Dim wsWS3 As Worksheet  'Sheet3


    Set wsJL = Sheets("Jobs List")      'Jobs List
    Set wsPOT = Sheets("PO Tracking")   'PO Tracking
    Set wsTNO = Sheets("Tel-Nexx OOR")  'Tel-Nexx OOR
    Set wbBK2 = Workbook("Book2")       'New Workbook
    Set wsWS1 = Sheets("Sheet1")        'Sheet1
    Set wsWS2 = Sheets("Sheet2")        'Sheet2
    Set wsWS3 = Sheets("Sheet3")        'Sheet3

        Application.ScreenUpdating = False    ' Prevents screen refreshing.
        CurrentFile = ThisWorkbook.FullName
        NewFileType = "Excel Files 2007 (*.xlsx)"
        NewFile = Application.GetSaveAsFilename(InitialFileName:="Open Order Log - " & Format(Date, "dd-mm-yyyy") & ".txt", fileFilter:=NewFileType)

End Sub

Why does this sub need to be defined? I am putting it as a standard module, and working on setting it up so that once a button is pushed I will be able to move a few pages over to a new workbook, delete the blank ones, and go from there with a save function that you tell it where to save.

I have a long way to go, but I wanted to test out the save function, and go from there, because to me that is going to be the hardest thing.

So without solving my entire conundrum, I would like to know why something like this needs to be defined? And how it needs to be defined… if someone could give an answer it be greatly appreciated.

  • 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-10T15:31:46+00:00Added an answer on June 10, 2026 at 3:31 pm

    You are misunderstanding the problem.

    The following line of code is incorrect. It does not create a new workbook like you think it does. The function Workbook does not exist – when you try to run/compile the VBA editor complains that the function does not exist.

    Set wbBK2 = Workbook("Book2")       'New Workbook
    

    Change it to

    set wbBK2 = Workbooks.add
    

    and it will create a new workbook and save a reference in wbBK2. Alternatively you could reference an open workbook by adding an “s” to Workbook if you are not trying to make a new one:

    Set wbBK2 = Workbooks("Book2")       'New Workbook
    

    You also will need to dimension these variables as strings eventually:

        Dim CurrentFile as String        
        Dim NewFileType as String
        Dim NewFile as String
    
        CurrentFile = ThisWorkbook.FullName
        NewFileType = "Excel Files 2007 (*.xlsx)"
        NewFile = Application.GetSaveAsFilename(InitialFileName:="Open Order Log - " & Format(Date, "dd-mm-yyyy") & ".txt", fileFilter:=NewFileType)
    

    Another note, too – when you use

    Set wsWS1 = Sheets("Sheet1")        'Sheet1
    Set wsWS2 = Sheets("Sheet2")        'Sheet2
    Set wsWS3 = Sheets("Sheet3")        'Sheet3
    

    You probably want to change this to reference the sheets in the other workbook

    Set wsWS1 = wbBK2.Sheets("Sheet1")        'Sheet1
    Set wsWS2 = wbBK2.Sheets("Sheet2")        'Sheet2
    Set wsWS3 = wbBK2.Sheets("Sheet3")        'Sheet3
    

    as it will be quite helpful to maintain the right references to these sheets, even if you add additional workbooks.

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

Sidebar

Related Questions

I have only recently started programming significantly, and being completely self-taught, I unfortunately don't
Being a self-confessed newbie I'm looking for some advice and guidance :) I have
Title is quite self explanatory, but I have some animation being done in a
Being mostly self-taught freestyle developer and having no experience of working in teams of
Background: I have a self-taught hobbyist level of understanding of C++, which has translated
As a self-taught python hobbyist, how would I go about learning to import and
I am relatively new to writing in C. I have self taught myself using
Being a self-taught newbie, I created a large problem for myself. Before inserting data
We have WCF services being self-hosted by a Windows Service inside our domain, using
Being fully self-taught without actually reading up on JavaScript (It's my job now, believe

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.