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

  • Home
  • SEARCH
  • 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 830555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:03:48+00:00 2026-05-15T04:03:48+00:00

I have a bunch of VBA code that I’d like to throw in a

  • 0

I have a bunch of VBA code that I’d like to throw in a macro.

Basically I call a bunch of subs that update the page.

It looks something like this:

Call Update1("Work", strConn)
Call Update2("Work", strConn)
Call Update3("Work", strConn)

where Update1, Update2, and update3 are all in the same sheet with the form

Public Sub Update1(strPlace, strConn)
SQL code..
End Sub

How would I throw it all in a macro? Could I copy and paste all the code (including the calls?) That hasn’t work. Neither has taking only the Subs. Not sure what’s next.

  • 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-05-15T04:03:49+00:00Added an answer on May 15, 2026 at 4:03 am

    All you should need is to insert a module as a container for all this code. Unless each of the
    UPDATE subs are specific to a single sheet, then they should probably be in the module as well.

    All of your “call” statements will need to be in their own SUB myMain () ... END SUB

    Once you’ve done this, you can either run it from the Tools, Macro list, or hook it into other events (a custom toolbar button or something else)

    Edit: to be more precise, this is what your module should look like:

    Sub myMainMacro()
        '... initialize stuff
        Call Update1("Work", strConn)
        Call Update2("Work", strConn)
        Call Update3("Work", strConn)
        '... do more stuff
    End Sub
    
    Sub Update1(strPlace, strConn)
        SQL code..
    End Sub
    
    Sub Update2(strPlace, strConn)
        SQL code..
    End Sub
    
    '... other UPDATE SUBs here
    
    Function CalculateValue(myInput as integer) as integer
        '... do calculations here
        CalculateValue = answer
    End Function
    

    All code (except for global variable declarations, which we haven’t talked about) needs to be inside a SUB or a FUNCTION (a function returns a value, a SUB does not). Since they are all in the same module, the keyword PUBLIC isn’t necessary.

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

Sidebar

Related Questions

I have an Excel file that has a bunch of VBA and macro code
I have a bunch of generic code that is used a lot, which i'd
I have a bunch of strings in php that all look like this: 10
I have a bunch of functions with signatures like: FUNCTION func1 (par1 IN VARCHAR2,
I have a bunch of html with lines like this: <a href=# rel=this is
I have a bunch of python methods that follow this pattern: def delete_session(guid): conn
I have a bunch of these little bits of HTML code repeated over and
I have bunch of objects that return a DOM-tree that I then use to
I have VBA code to run a query in SQL-Server 2008. It runs fine
For example I have bunch of functions like these: function a() { //do something

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.