PDA

View Full Version : User Input



allison
04-07-2008, 08:08 AM
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:


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



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?

rory
04-07-2008, 08:34 AM
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.