Luis Neves said:
i've a macro(on "book1.xls") with a userform with a button1 inside , i
just want on click event of the button1 write : "Hello World!!" on
book2.xls ... Is this possible ?
Yes, Luis, this is fairly simple
Add following code to button1 on the useform
Workbooks.Open "book2.xls"
ActiveSheet.Range("a1") = "Hello World"
This will what you want. Of course you have to make sure, that Excel will
find the Book2.xls. No path is needed if it is in the same path as Book1,
otherwise you will have to add the path as well.
If there is more than 1 sheet in Book2, you will have to select the wanted
sheet by a statement like Sheets("My sheet").select before the Activesheet
statement above.
If you want to close and save Book2 from the same userform, add another
bottom with code like
Workbooks("book2.xls").Close (savechanges = True)
Mind you, there is a whole world to check: does Book2 exist; is it already
open; is it open when you want to close it.
good luck, Ko Vijn