+ Reply to Thread
Results 1 to 6 of 6

Running a code across multiple sheets

  1. #1
    Registered User
    Join Date
    06-10-2012
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    30

    Running a code across multiple sheets

    Hi,

    I'm new to this forum and VBA. As I am a quite good general Excel user, I've been tasked with creating an automated forecasting spreadsheet at work. It is made up of a front sheet and multiple tabs depicting various statistical measures.

    I've already got parts of the spreadsheet working, e.g:
    1. On the 1st tab the user is asked to enter a date via an input box. This date is used to search for and open files in a location that contain the date entered by the user as a suffix (the original tables are created and output using SAS)
    2. On the 2nd tab, data is fed into a standard form using vlookup
    3. On the 3rd tab, data is fed in from a specified external location

    My predicament is that although the pieces of code run in isolation on the individual sheets, the code isnt executed all the way through for all the sheets. Another thing is that although the date entered by the user can be used within the worksheet that contains the code, it has to be restated for other sheets in the workbook. Why is this? I've tried making the date field public but this doesn't work.

    I'm sure the solution to this is very simple and I'm just being daft. Would appreciate any help with this at all.

    Thanks

  2. #2
    Forum Contributor
    Join Date
    06-07-2012
    Location
    London, England
    MS-Off Ver
    Excel 2010
    Posts
    189

    Re: Running a code across multiple sheets

    It probably is a simple fix. Try posting your code.

  3. #3
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,366

    Re: Running a code across multiple sheets

    Hi Swootie and welcome to the forum.

    It sounds like you have code behind each sheet and need to move code to a Module Level. Read
    http://www.cpearson.com/Excel/Scope.aspx
    for a better discription of scope of variables and how code intereacts with sheets, workbooks and userforms.

    If this doesn't help then I've missed on understanding what is happening and keep asking questions.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  4. #4
    Registered User
    Join Date
    06-10-2012
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Running a code across multiple sheets

    Thank you very much for the warm welcome and your prompt responses. I will try moving my code to module level to see if that helps when I return to work tomorrow. Will keep you all updated.

    Thanks again.

  5. #5
    Registered User
    Join Date
    06-10-2012
    Location
    Leeds
    MS-Off Ver
    Excel 2003
    Posts
    30

    Re: Running a code across multiple sheets

    It works at module level. That must have been where I was going wrong. Thank you for your help.

  6. #6
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,366

    Re: Running a code across multiple sheets

    I'm glad you got it working.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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