+ Reply to Thread
Results 1 to 5 of 5

How do I automate updating VBA modules

  1. #1
    Registered User
    Join Date
    04-27-2009
    Location
    Oklahoma City, USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    How do I automate updating VBA modules

    I have a spreadsheet that has multiple macros. They are stored in multiple Modules. Each macro contains a reference to a week number, i.e. Week 5. I want to automate this so I can enter the week number as a variable somewhere and have the different macros updated with the new week number.

    I don't know how to do that. In the past I have recorded macros and then edited them. But doing that does not work, as the new recorded macro stops as soon as you select "edit" for the existing macro.

    Would someone please point me in the right direction on how to accomplish this?

    Thanks,
    Kevin

  2. #2
    Forum Expert
    Join Date
    10-10-2016
    Location
    Sheffield
    MS-Off Ver
    365 and rarely 2016
    Posts
    3,212

    Re: How do I automate updating VBA modules

    Decide the week number, either by entering it in a dialog box or just putting it in a cell and referencing the cell. Then declare its scope

    http://www.excel-easy.com/vba/exampl...ble-scope.html

  3. #3
    Registered User
    Join Date
    04-27-2009
    Location
    Oklahoma City, USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How do I automate updating VBA modules

    Thanks for the reply davsth.

    I have declared a variable in the declaration section to be used in all the modules - Public wk As String

    I have created a Range on one of the worksheets named "week"

    In my module I put: wk = Range("week").Select

    When I run it I get an error saying "Unable to get the Select property of the Range class".

    I tried it without the quote marks - Range(week).Select. It liked that even less.

    I tried identifying the specific worksheet - wk = ActiveWorkbook.Worksheets("AgainstTheSpread").Range("week").Select. Got the same error message that it is unable to get the Select property.

    Any clue as to what I am doing wrong?

    Thanks,
    Kevin

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: How do I automate updating VBA modules

    Don't select:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    04-27-2009
    Location
    Oklahoma City, USA
    MS-Off Ver
    Excel 2007
    Posts
    8

    Re: How do I automate updating VBA modules

    Thanks Kyle! That did it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. macro 4 sheet Mysterious appearing Worksheets & Modules. Codes transferred to New Modules
    By Doc.AElstein in forum Excel Programming / VBA / Macros
    Replies: 12
    Last Post: 07-24-2016, 07:07 AM
  2. Updating code hassle - automate the process
    By saechaoc in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-24-2015, 04:31 PM
  3. Replies: 4
    Last Post: 06-20-2015, 01:33 AM
  4. How to automate the quarterly manual updating of over 100 graphs?
    By Mirisage in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 10-17-2014, 11:15 AM
  5. How to Automate Updating Column Headers Across Dozens of Spreadsheets
    By Startup in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-29-2013, 11:12 AM
  6. Replies: 0
    Last Post: 07-05-2012, 03:44 PM
  7. Problems Updating Modules
    By erich_7719 in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 04-12-2008, 02:36 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1