Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you Write Data to an exel worksheets

Status
Not open for further replies.

CVL1975

Programmer
Aug 26, 2002
2
US
Maybe someone can help me with this. I have an excel worksheet template call MyExcelTemplate, it has 3 worksheets(Sheet1,sheet2,sheet3)and I want to write data to sheet1,sheet2,sheet3 from Visual Basic.Anyones can help me with this?.
I am truly appreciated.
Thanks,
CVL
 
What do you mean "write data" - do you want to fill in cells with set data or formulae. Will the data change or will it stay the same. Need more info if you want examples Rgds
~Geoff~
 
Do a search for "Excel.Application" (without the quotes) in this forum. You will get hundreds of samples for this.
 
sub write_data()

sheets("sheet1").range("a1")="vba code wrote this"

end sub
 
easier to use:

sheets(x).range("a1")="vba code wrote this"

Where x is the number of the sheet.

Or create an object representing the cell:

set currentcell = worksheets(sheetnumber).cells(x,y)
currentcell.value = "vba code wrote this"

This makes for neater code when looping thru columns or rows.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top