Consulting

Results 1 to 2 of 2

Thread: User Input

  1. #1
    VBAX Regular
    Joined
    Feb 2008
    Posts
    58
    Location

    User Input

    I'm working on taking some data and creating two types of reports - one at the department level, one at the team level. I've been writing the code in short steps (probably shorter than most do, but it's been easier as I'm learning) - and then I'll combine them at the end with one routine that calls all of the short ones.

    I started with the team level reports and it's working properly. In one of the subroutines, I have this code:

    [vba]
    UserEntry = InputBox("What month is being reported?")
    If UserEntry <> "" Then Range("A1").Value = UserEntry

    [/vba]

    The UserEntry value is used to rename worksheets that are added to each team's workbook.

    Now, I'm working on the department level report and need that same information - and I do not want to have to ask someone to key it in for the 2nd time. The month will always be the same between the two sets of reports - and it doesn't matter which of the reports are generated first - team or department.

    I have not yet passed variables/arguements between routines before, and I didn't think that UserEntry is considered a variable because it's not defined as one - so I'm not sure to solve this problem. Any suggestions?

  2. #2
    VBAX Master
    Joined
    Jun 2007
    Location
    East Sussex
    Posts
    1,110
    Location
    UserEntry is a variable whether or not you declare it (it just ends up as a Variant if you don't declare it otherwise). Since you write the value to a worksheet, you could simply use that cell value in each subsequent routine, or you could declare the variable Public at the top of your module, or you could pass it to each subsequent routine as an argument.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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