View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.misc
petercoe
 
Posts: n/a
Default Excel, adding figures from one cell to a summary sheet or workbook

Thank you, Dave.
I have to learn all of this. As soon as I know, I will let you know how
this worked out.
Pete



Dave Peterson wrote:
Maybe...

If all the workbooks are in the same folder and you pick up the same cell from
the same worksheet each time, you could use something like:

Option Explicit
Sub testme01()

Dim myFileNames As Variant
Dim RptWks As Worksheet
Dim wkbk As Workbook
Dim fCtr As Long

myFileNames = Application.GetOpenFilename("Excel Files, *.xls", _
MultiSelect:=True)

If IsArray(myFileNames) = False Then
Exit Sub
End If

Set RptWks = Workbooks.Add(1).Worksheets(1) 'single sheet

For fCtr = LBound(myFileNames) To UBound(myFileNames)
Set wkbk = Workbooks.Open(Filename:=myFileNames(fCtr))
RptWks.Cells(fCtr, "A").Value = myFileNames(fCtr)
RptWks.Cells(fCtr, "B").Value _
= wkbk.Worksheets("sheet1").Range("a1").Value
wkbk.Close savechanges:=False
Next fCtr
End Sub

When you're prompted for what file to open, click on the first and ctrl-click on
subsequent (or shiftclick to extend your selection of files).

And remember to change the sheet name to what you want and the address, too--on
this line:

= wkbk.Worksheets("sheet1").Range("a1").Value

If you're new to macros, you may want to read David McRitchie's intro at:
http://www.mvps.org/dmcritchie/excel/getstarted.htm



petercoe wrote:

We are using a template for rental invoicing. There is one cell that
adds a damage waiver premium of 2% or 10% of the rental cost. In one
cell I make the choice of 2 or 10 and the amount automatically appears
in the damage waiver cell. We save the invoices as R1001, R1002, R1003
and so on. I need to extract the damage waiver costs in two different
totals, one for the 2% charge and one for the 10% charge because we
have to pay different percentages as insurance premiums for these
charges at the end of each month. Is there a way to do this
automatically so I don't have to view each invoice and add manually?

Tia, Petercoe


--

Dave Peterson