![]() |
writing on cells
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 ? |
writing on cells
Private Sub commandButton1_Click()
Workbooks("book2.xls").worksheets(1).Range("A1").V alue = _ "Hello World!" End Sub -- Regards, Tom Ogilvy Luis Neves wrote in message om... 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 ? |
writing on cells
"Luis Neves" 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 |
All times are GMT +1. The time now is 07:23 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com