Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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 ?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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 ?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
indirect writing in cells aolsson Excel Discussion (Misc queries) 2 July 17th 06 11:45 AM
how do I skip blank cells when writing formulas KatB Excel Worksheet Functions 1 July 11th 06 09:53 PM
Writing inside the Cells also Octavio New Users to Excel 2 January 27th 06 02:30 PM
Writing to cells skrol New Users to Excel 2 September 10th 05 03:37 PM
writing cells with variables from vba josh ashcraft Excel Programming 0 July 17th 03 03:32 PM


All times are GMT +1. The time now is 06:55 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"