View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.setup
Sean Sean is offline
external usenet poster
 
Posts: 208
Default Help ! How do I do this in VB Script

I have a spreadsheet with a Summany sheet and 235 deatil sheets.

I have various scripts that create the tabs, which are basically a summary
of monthly values for each of our suppliers.

I want to use vbscript to add totals to each supplier sheet but im having
great difficulty in doing what i want in a short piece of code.

I can do it for an individual supplier with the following code:

Private Sub CommandButton1_Click()


Sheets("ACME").Select

ActiveSheet.Range("C18").Value = "TOTALS"
ActiveSheet.Range("D18").Value = "=sum(D5:D16)"
ActiveSheet.Range("E18").Value = "=sum(E5:E16)"
ActiveSheet.Range("F18").Value = "=sum(F5:F16)"
ActiveSheet.Range("G18").Value = "=sum(G5:G16)"
ActiveSheet.Range("H18").Value = "=sum(H5:H16)"
ActiveSheet.Range("I18").Value = "=sum(I5:I16)"
ActiveSheet.Range("J18").Value = "=sum(J5:J16)"
ActiveSheet.Range("K18").Value = "=sum(K5:K16)"
ActiveSheet.Range("L18").Value = "=sum(L5:L16)"

End Sub

But I dont want to have to creat 200+ procedures to fill in totals for each
supplier so how do I change sheets and put the above onto each one.

The main sheet has a list of Supplier names from cell A5 to A200+ so I can
pick them from there but how do I do this ?

Im sorry if this does not make sense but have been trying to do this for
hours and is driving me mad.

Thanks for any help

Sean