Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have developed a macro that does a whole bunch of things for me based on a few things. (Importing files).

The file names are dated dd_mm_yyyy and right now I enter them into a sheet where the macro can retrieve the information. Not really wanting this I designed a userform where the user can enter the "dd", "mm", "yyyy" and how many consecutive days of files there are.

For example:

28_06_2011.txt

29_06_2011.txt

there would be one consecutive day.

I want to be able to retrieve the information entered in the userform (day, month, year, and consecutive days) to use in the macro and have been unsuccessful because I don't know how to access that information. Is it similar to referring to a range in a worksheet?

The userform I designed

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Use Something like:

Me.Textbox1.Value

Every control has a name, which you can get (and set) by right-clicking on the textbox in design mode and choosing properties.

'Me' refers to the Form itself.

share|improve this answer
1  
I realize I can use it to program the Userform itself but can I use the "Me" Object(?) inside the macro? When i tried to use the user-form to set variables for the macro it didn't work. –  B-Ballerl Jun 29 '11 at 4:34
    
You can also pass parameters or use a class or a global. Global variables would be the easiest, but also the easiest to mess up, but I've used a few in VBA when I needed them. –  Lance Roberts Jun 29 '11 at 4:42
    
It worked, I guess I just didn't understand the idea that the "textbox1" was an object and held a value. Like the comparison worksheet to a cell or range as a userform is to a field or control –  B-Ballerl Jul 1 '11 at 7:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.