Results 1 to 9 of 9

Condense code

Threaded View

tone640 Condense code 09-01-2011, 07:10 AM
MaczaQ Re: Condense code 09-01-2011, 08:13 AM
tone640 Re: Condense code 09-01-2011, 09:46 AM
MaczaQ Re: Condense code 09-01-2011, 01:33 PM
tone640 Re: Condense code 09-02-2011, 03:52 AM
snb Re: Condense code 09-02-2011, 04:12 AM
tone640 Re: Condense code 09-02-2011, 06:52 AM
snb Re: Condense code 09-02-2011, 07:29 AM
tone640 Re: Condense code 09-02-2011, 08:25 AM
  1. #7
    Forum Contributor
    Join Date
    06-15-2011
    Location
    Chester, England
    MS-Off Ver
    Excel 2013
    Posts
    117

    Re: Condense code

    Even better snb, thanks for your suggestion.

    I'm using the following now (ADV sheets are a special case that need a bit extra info, and slightly amended formula to SUM):

    For Each ws In Worksheets
            If ws.Name <> "Invoice" Then
                Select Case ws.Name
                Case "ADV"
                Sheets("Invoice").Range("J22") = "=SUM(" & ws.Name & "!C[17])"
                Range("B2", Range("A65536").End(xlUp).Offset(, 1)).FormulaR1C1 = "=VLOOKUP(RC[-1],'[Timesheet import.xlsm]Completions'!C1:C2,2,0)"
                Range("B2", Range("A65536").End(xlUp).Offset(, 1)) = Range("B2", Range("A65536").End(xlUp).Offset(, 1)).Value
                Case Else
                Sheets("Invoice").Range("J22") = "=SUM(" & ws.Name & "!C[17])"
                End Select
            End If
        Next ws
    -edit: The workbook will consist of 1 of the following 7 combinations of sheets:

    "Invoice" and "Completes"
    "Invoice" and "Aborts"
    "Invoice" and ...
    "Invoice" and ...
    "Invoice" and ...
    "Invoice" and ...
    "Invoice" and ...

    So the formula is only entered once on "Invoice" to sum the backing data.

    Again, many thanks both for your help.
    Last edited by tone640; 09-02-2011 at 06:58 AM. Reason: Clarifying, spelling

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1