Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Copying multiple worksheets to a template using vb.net

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
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
Copying multiple cells out of multiple worksheets at same time. tom Excel Discussion (Misc queries) 1 April 2nd 10 09:03 PM
Populate central worksheet template from multiple worksheets wcurtis Excel Discussion (Misc queries) 0 December 24th 08 10:10 PM
copying from multiple worksheets M John Excel Programming 7 May 9th 06 07:50 PM
Copying multiple Worksheets Dor474c Excel Discussion (Misc queries) 0 June 29th 05 10:10 PM
Copying from multiple worksheets GMP Excel Discussion (Misc queries) 4 May 6th 05 12:59 AM


All times are GMT +1. The time now is 06:35 PM.

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"