PC Review


Reply
Thread Tools Rate Thread

Copying multiple worksheets to a template using vb.net

 
 
irishrose
Guest
Posts: n/a
 
      17th Jul 2008
I am really new to programming Excel with vb.net. I have created a template
that has 4 features on it. Basically they are 4 different tables with the
same headings. I generate the worksheets that will populate the data on the
template. The first cell on the worksheet is feature name, the next row
starts the data and there are 3 columns of data, that can be varying lengths
for each feature. I need a function that will go through each sheet and
populate the template. Since the template only holds 4 features, if there are
more than 4 features it will have to create another sheet with the rest of
the features. The worksheets generate fine and the feature name is the tab
name and no two tabs have the same name. Now how do I go about getting the
data copied to the template.

This is the code that generates the worksheets.

PrivateSub BuildStations(ByRef pPspaObjects As clsPSpaObjects)

Dim oStation As clsStation

Dim oSheet As Excel.Worksheet

Dim oPspaObject As clsPSpaObject

Dim a AsInteger

' select the readings sheet

ForEach oPspaObject In pPspaObjects

oSheet = LocalDocument.Sheets.Add()

oSheet.Name = oPspaObject.Name

oSheet = SetActiveSheet(LocalDocument, oPspaObject.Name)

a = 2

With oSheet

' series name

ForEach oStation In oPspaObject.Stations

..Cells(1, 1) = oPspaObject.Name

..Cells(a, 1) = oStation.StationNumber

..Cells(a, 2) = oStation.CalculateModulus

..Cells(a, 3) = oStation.CalculateFlexStrength

a += 1

Next

EndWith

Next

EndSub


PublicSub GenerateReport(ByRef pPspaObjects As clsPSpaObjects)

Dim sFileName AsString

Dim oPSpaObject As clsPSpaObject

Dim oName AsString

sFileName = System.AppDomain.CurrentDomain.BaseDirectory & "\Reports\PSPA.xlt"

IfNot System.IO.File.Exists(sFileName) Then

MsgBox("Template not found")

ExitSub

EndIf

' open excel

Application = New Excel.Application

Application.Visible = True

' open work book

LocalDocument = OpenExcelDocument(sFileName)



' add data for stations to spreadsheet

BuildStations(pPspaObjects)



Application.Visible = True

EndSub

Any help would be appreciated.

Thanks in advance!

--
Irishrose
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Copying multiple cells out of multiple worksheets at same time. tom Microsoft Excel Misc 1 2nd Apr 2010 09:03 PM
Copying from Multiple Worksheets BaggieDan Microsoft Excel Programming 2 15th Oct 2009 10:07 PM
Copying multiple worksheets to a template using vb.net irishrose0312 Microsoft Excel Programming 0 17th Jul 2008 02:52 PM
copying from multiple worksheets =?Utf-8?B?TSBKb2hu?= Microsoft Excel Programming 7 9th May 2006 07:50 PM
Copying multiple Worksheets =?Utf-8?B?RG9yNDc0Yw==?= Microsoft Excel Misc 0 29th Jun 2005 10:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:33 AM.